If you are creating a ListActivity with a CursorAdapter (or
SimpleCursorAdapter), then you may want to have the list updated at
some point. I had a little trouble figuring this out myself, so I
thought I'd post how to do it.
After updating your database, you want to get the cursor from the
adapter and call the Cursor.requery() method on it. This is the
method I've created for my list activity class. Please note that the
BaseCursor.notifyDataSetChanged() method doesn't update the list (at
least not for me).
/**
* Refreshes this list
*/
private void refreshList() {
if (getListAdapter() == null || !(getListAdapter() instanceof
CursorAdapter)) {
return;
}
CursorAdapter ca = (CursorAdapter) getListAdapter();
if (ca.getCursor() == null) {
return;
}
ca.getCursor().requery();
}
Thanks,
Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---