Alternative to requery on Android honeycomb
As google in there "wisdom" has ditched requery on cursor I am looking for alternatives.
http://developer.an开发者_JS百科droid.com/reference/android/database/Cursor.html
It helpfully says "Just request a new cursor, so you can do this asynchronously and update your list view once the new cursor comes back."
However does this mean I now need to keep a record of the search run on each cursor so I can run it again ??
Wondering what people are doing.
CursorLoader
works great with ListView
and CursorAdapter
. The problem is that you'll have to write your own ContentProvider
. This is not that much of work and is very worth it.
If you are using the Cursor without putting it in an Adapter
you can probably use AsyncQueryHandler
instead and manually observing changes via Cursor.registerContentObserver()
. Note that this approach also requires a ContentProvider
.
If you really don't want to implement a ContentProvider
you'll have to implement your own async query method or stick to requery()
, don't do this though.
精彩评论