How to requery for a cursor now if requery is deprecated?
Asked Answered
H

4

7

As per the title, if we used to call cursor.requery(), but it is now deprecated. How do you call this function now?

This method is deprecated. Don't use this. Just request a new cursor, so you can do this asynchronously and update your list view once the new cursor comes back.

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

Hurter answered 23/8, 2011 at 6:22 Comment(0)
C
2

Re-initialize cursor when your any DML query execute.

See also this.

Clough answered 23/8, 2011 at 6:35 Comment(0)
E
2

Just think about a block where you need to use cursor again and again. Populate it with the query. Work with it and then close before reusing

{
    Cursor c =//Populating cursor again
    while (c.moveToNext()) {
    }
    if (c != null) c.close();
}
Epithelium answered 23/8, 2011 at 6:30 Comment(0)
C
2

Re-initialize cursor when your any DML query execute.

See also this.

Clough answered 23/8, 2011 at 6:35 Comment(0)
B
1

Use a Loader to manage your cursors. It will return a new Cursor as needed and you can use swapCursor() on the adapter to refresh the data.

Bremer answered 23/8, 2011 at 6:29 Comment(1)
You can use the compatibility library, it works with 1.6 and up. Or, if you don't care about Honeycomb, leave it as is.Bremer
C
-1

I used ListAdapter.notifyDataSetChanged(); this worked only on list (like ArrayList), when the listcontent changed. Using databaseoutput, it doesn't work anymore. Therefore I took cursor.requery(); which is not only depricated. It also works only, if database entries changed.

But now, I want to change my view (switch between birthdays and dates) by changing my settings in a database, so requery does not recognize it.

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

Cacia answered 30/9, 2013 at 21:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.