Hello!

I'm experiencing a problem that I fail to understand, maybe somebody
can help.

I'm using a MergeCursor in a ListActivity and a ResourceCursorAdapter.
The MergeCursor consists of several Cursors that come from regular
ContentProvider queries.
After constructing the MergeCursor, I call startManagingCursor on it -
I followed that pattern before without a problem.

My problem is that sometimes (not all the time), going to another
Activity and coming back, I receive this exception:

android.database.StaleDataException: Access closed cursor
    at
android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:
175)
    at
android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:
99)
    at android.database.CursorWrapper.getLong(CursorWrapper.java:127)
    at android.database.MergeCursor.getLong(MergeCursor.java:142)
    at android.widget.CursorAdapter.getItemId(CursorAdapter.java:156)
    at android.widget.AdapterView.rememberSyncState(AdapterView.java:
1085)
    at android.widget.AdapterView
$AdapterDataSetObserver.onChanged(AdapterView.java:784)
    at
android.database.DataSetObservable.notifyChanged(DataSetObservable.java:
31)
    at
android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
    at android.widget.CursorAdapter
$MyDataSetObserver.onChanged(CursorAdapter.java:385)
    at
android.database.DataSetObservable.notifyChanged(DataSetObservable.java:
31)
    at android.database.AbstractCursor.requery(AbstractCursor.java:97)
    at android.database.sqlite.SQLiteCursor.requery(SQLiteCursor.java:
561)
    at android.database.CursorWrapper.requery(CursorWrapper.java:211)
    at android.database.MergeCursor.requery(MergeCursor.java:247)
    at android.app.Activity.performRestart(Activity.java:3522)
    at
android.app.ActivityThread.performRestartActivity(ActivityThread.java:
2967)
    at
android.app.LocalActivityManager.moveToState(LocalActivityManager.java:
160)
    at
android.app.LocalActivityManager.startActivity(LocalActivityManager.java:
321)
   (...)

My understanding of it is that my managed cursor was deactivated, then
going back it is requeried, but doing so a notification is sent to my
adapter (DataSetObservable.notifyChanged). So the adapter then tries
to access the cursor... which is in the middle of the requery, and so
this exception is raised!

What did I do wrong?

Thanks,

BoD

-- 
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