Android, how do you code now if requery is out of date?

according to the topic. If we used the cursor.requery () call, but now it's deprecated, what do you call this function now?

"This method is deprecated. Do not use it. Just request a new cursor so you can do it asynchronously and update the list view after the new cursor returns."

So, how to request a new cursor and pass it back to the adapter?

+7
source share
4 answers

reinitialize the cursor again when your any DML request is executed, may refer to this

+3
source

Just think of a block where you need to use the cursor over and over. Fill it with a request. Work with it and then close before reuse

{ Cursor c =//Populating cursor again while (c.moveToNext()) { } if (c != null) c.close(); } 
+2
source

Use Loader to control your cursors. It will return a new cursor as needed, and you can use swapCursor() on the adapter to update the data.

+1
source

I used ListAdapter.notifyDataSetChanged () ; this only worked on the list (e.g. ArrayList) when the content list changed. Using databaseoutput, it no longer works. So I took cursor.requery (); which is not only destitute. It also works only when changing records in the database.

But now I want to change my view (switch between birthdays and dates) by changing my settings in the database, so requery won't recognize it.

For all changes it works (a little dirty): this.onCreate (null);

-one
source

All Articles