I am trying to change Cursor
in CursorAdapter
this way:
Cursor newCursor = compiledStatement.getCursor();
startManagingCursor(newCursor);
adapter.changeCursor(newCursor);
Unfortunatelly I get this exception:
java.lang.IllegalStateException: attempt to re-open an already-closed object:
android.database.sqlite.SQLiteQuery
According to other topics, it should be possible to change content of CursorAdapter without creating new one.
I have found the problem. My
CursorAdapter
implementsSectionIndexer
, so I had to owerwritechangeCursor()
method and reset theCursor
forAlphabetIndexer
.changeCursor()
will close the previous Cursor, which is still managed by the Activity, that is probably the reason you are getting the exception. You might try callingstopManagingCursor()
on the old cursor before you callchangeCursor()
.