简体   繁体   中英

Android SimpleCursorAdapter Update when database updates

I have an application that uses SyncService and SyncAdapter. Within the application, I have an activity using a SimpleCursorAdapter. How do I go about updating the list when the database updates?

I have read that I should use adapter.changeCursor() or notifyDataSetChanged() , but where do I call it? And how would I know when the database is updated?

Also, I have heard that I could use a ContentProvider instead of a direct database access and the list would update automatically, is that true?


I update the database in the method onPerformSync() in my SyncAdapter class

You can use notifyDataSetChanged() like:

mListView.setAdapter(someAdapter);
someAdapter.notifyDataSetChanged();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM