I'm using the deprecated SimpleCursorAdapter to display data from Cursor to ListView. I've added the additional argument 0
, which removes the dreprecated warning, but I want to use a better way to display data. I've read something about Loader
, but don't know how to implement it. What would be a better alternative to the code below? How would this code be translated to use Loader?
Cursor c = mDbHelper.getAllRecords();
startManagingCursor(c); //this is also deprecated
String[] from = new String[] { "Name" };
int[] to = new int[] { R.id.text1 };
SimpleCursorAdapter names =
new SimpleCursorAdapter(this, R.layout.names_row, c, from, to, 0);
setListAdapter(names);
adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2, cursor, from, to, 1);
This will do the automatic requery. 1 is set to true and 0 to false.
SimpleCursorAdapter isn't deprecated, just the constructor.
see SimpleCursorAdapter deprecated in API version 15?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With