Hi,

I have been trying to take database reads off the UI thread and am currently 
using an AsyncTask, however I am running into trouble swapping out an updated 
Cursor for a new one in the adapter.
(I was previously using requery() on the Cursor which had to be on the main UI 
thread)

The documentation regarding requery() says:
"Just request a new cursor, so you can do this asynchronously and update your 
list view once the new cursor comes back."

If I update the existing Cursor (mCursor) with the results from a new query and 
do the following in onPostExecute of an AsyncTask:

        mAdapter.changeCursor(mCursor);
        
it works pretty well on a Nexus 1.  On other devices I am getting errors 
because I haven't closed the old Cursor. 
(java/lang/IllegalStateException;: Finalizing cursor 
android.database.sqlite.SQLiteCursor on null that has not been deactivated or 
closed)

I have tried creating a new Cursor and swapping the Cursors out like so:

                        if(null!=mArtists)
                                mCursor.close();
                        mArtists = newCursor;

but I get performance issues and the view of the list goes back to the top.

Has anyone got any ideas on this?  Alternatively does anyone have or know of 
any documentation for using a CursorLoader against a SQLiteDatabase rather than 
a ContentProvider?

Thanks for any help.  

Regards,
Julius.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to