views:

52

answers:

1

I have a ListView populated via a CursorAdapter. I give my user the ability to alter the data in the list. For example, the user can mark a row as being unread (the data are messages).

Suppose my user marked a row unread. Would a proper implementation mark the row in the database as read and then requery the Cursor?

+2  A: 

Would a proper implementation mark the row in the database as read and then requery the Cursor?

Yes, that's the right answer. The requery() will trigger an automatic update of your CursorAdapter, which will trigger an automatic update of the ListView, which will trigger an automatic smile from the user. :-)

CommonsWare
I like smiling users!
Andrew
I just didn't know how heavy requery() was and if it was the proper thing to do for changing 1 small piece of data
Andrew
@Andrew: You don't have a choice. A `Cursor` is immutable except via `requery()`, so there's no other way for you to get the data in there. Your only alternative would be to schlep all the `Cursor` data into some other data structure, and that would be slow and painful.
CommonsWare