Can Someone Explain To Me This `staledataexception`
Can someone explain to me this StaleDataException 07-11 19:58:23.298 E/AndroidRuntime( 1044): Uncaught handler: thread main exiting due to uncaught exception 07-11 19:58:23.368 E/A
Solution 1:
You are trying to retrieve information from a Cursor
that has already been closed. You must verify whether the cursor is closed or not by using the isClosed
method.
Solution 2:
You can't close the cursor until CursorAdapter is no longer needed. So you can close it in onDestroy() method:
@Override
public void onDestroy() {
super.onDestroy();
//Close the cursorcursor.close();
//Close the database
database.close();
}
Solution 3:
In my case, I was closing the cursor in the onStop() method. It turned out that the rotation of the screen was causing this code to run and hence give the StaleDataException.
Solution 4:
Use Activity.getContentResolver.query()
instead of Activity.managedQuery()
. Because managedQuery()
is deprecated. It works for me.
Post a Comment for "Can Someone Explain To Me This `staledataexception`"