Proper implementation of changing ListView data using CursorAdapter

I have a ListView populated with a CursorAdapter. I give my user the ability to change the data in the list. For example, a user may mark a line as unread (data represents messages).

Suppose my user marked an unread line. Will the correct implementation mark the row in the database as read, and then request the cursor?

+4
source share
2 answers

Will the correct implementation mark the row in the database as read, and then request the cursor?

Yes, that is the correct answer. requery() will automatically update your CursorAdapter , which will automatically update the ListView , which will cause the user to smile automatically. CursorAdapter

UPDATE

The requery() method is deprecated. Currently, it is best to run a query to get a fresh Cursor , and then use changeCursor() or swapCursor() on the CursorAdapter .

+6
source

If the cursor returns to the ContentProvider, and the ContentProvider gives the correct notifications, the CursorAdapter is automatically updated, that is, without the need to issue an explicit request ().

0
source

All Articles