tags:

views:

417

answers:

1

Hi,

I have a ListView which as a CursorAdatper as its adatper. I would like to have the list view to * requery its data * refresh its view once the requery is done.

I tried:

CursorAdapter adapter = (CursorAdapter)listView.getAdapter();
adapter.notifyDataSetChanged();

And i tried: CursorAdapter adapter = (CursorAdapter)listView.getAdapter(); adapter.getCursor().requery();

both do not work. I have set up a break point in my ContentProvider's query method, but I don't see the requery is being called and my ListView is refreshed with new data.

Can you please tell me what is the solution to my problem?

Thank you.

+2  A: 

Calling requery() on a database or content provider Cursor attached to ListView via a CursorAdapter automatically refreshes the list (your second scenario above). You can see some examples of this. If that is not working for you, there may be some bug in your ContentProvider or adapter.

CommonsWare
Thank you for your help.
hap497