I've an android list activity that's backed with a database cursor via a SimpleCursorAdapter.
Once the products are clicked on, a flag area within the coresponding row within the database is toggled and also the view within the list must be up-to-date.
The issue is, once the view that's up-to-date chimes screen and it is recycled, that old value is shown on the vista if this returns into view. Exactly the same factor happens whenever thr list is redrawb (orientation changes, etc).
I personally use notifydatasetchanged() to refresh the cursor adapter however it appears ineffective.
How must i be upgrading the database therefore the cursor is up-to-date too?
requery() around the
Cursor whenever you change data within the database that you would like reflected for the reason that
Cursor (or things the
Cursor populates, just like a
ListView using a
Cursor is similar to an ODBC client-side cursor -- it holds all the data symbolized through the query result. Hence, simply because you alter the information within the database, the
Cursor won't learn about individuals changes unless of course you refresh it via
requery has become deprecated. in the documentation:
This process is deprecated. Avoid using this. Just request a brand new cursor, so this can be done asynchronously increase your list view when the new cursor returns.
after acquiring a brand new cursor it's possible to make use of the
adapter.changeCursor(cursor). this will update the vista.