Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to refresh the listView using the Cursor Adapter
    text
    copied!<p>I have created a <code>ListView</code> using <code>CursorAdapter</code> . Now I am Trying to update the <code>ListView</code> and Refresh the value to the ListView .</p> <p>But I am not able to figure out . How to work with <code>Loader</code> or <code>changeCursor()</code> to refresh my <code>ListView</code></p> <p>Below is My code of setting the <code>CursorAdapter</code> :</p> <p>//SucessFully done here</p> <pre><code>SQLDataSore datastore = new SQLDataSore(PrintContent.this); Cursor cursor = datastore.getJSONData(); final CursorDemo cursorDemo = new CursorDemo(PrintContent.this, cursor); list_View.setAdapter(cursorDemo); </code></pre> <p>My <code>Button</code> <code>onClick</code> I am updating the Value into the Database //SucessFully Done</p> <pre><code>btn_check.setOnClickListener( new OnClickListener() { @Override public void onClick(View view ) { String editTextValue = edit_check.getText().toString(); if (editTextValue!=null) { SQLDataSore sqlDataSore = new SQLDataSore(PrintContent.this); Cursor cursor_update = sqlDataSore.updateData(editTextValue); //Here How Should I update my ListView ...? } } </code></pre> <p>My UpdateData Method:</p> <pre><code>public Cursor updateData(String editContent){ SQLiteDatabase updateContent = getReadableDatabase(); Cursor cursor_update = updateContent.rawQuery( "update " +TABLE_NAME + " set content = '"+ editContent +"' "+" where _id = 357", null); return cursor_update; } </code></pre> <p>CursorDemo Class</p> <pre><code>public class CursorDemo extends CursorAdapter{ public CursorDemo(Context context, Cursor c) { super(context, c , false); // TODO Auto-generated constructor stub } @Override public void changeCursor(Cursor cursor) { // TODO Auto-generated method stub super.changeCursor(cursor); } @Override public void bindView(View view, Context context, Cursor cursor) { // TODO Auto-generated method stub TextView txt_content = (TextView) view.findViewById(R.id.txt_content); TextView txt_likes_count = (TextView) view.findViewById(R.id.txt_likescount); TextView txt_name = (TextView) view.findViewById(R.id.txt_name); TextView txt_display_name = (TextView) view.findViewById(R.id.txt_display_name); txt_content.setText(cursor.getString(cursor.getColumnIndex("content"))); } @Override public View newView(Context context , Cursor cursor, ViewGroup viewGroup) { // TODO Auto-generated method stub LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.message_row_view, viewGroup ,false); return view; } } </code></pre> <p>Any Help is Appreciated... });</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload