I always do like this:
MediaDbAdapter mDbHelper = null;
Cursor c = null;
try {
// Do you DB stuff
} catch( Exception e) {
// Something went wrong
}
// Close and cleanup
if ( c != null )
{
// You do not need to deactivate the cursor
c.close();
}
if(mDbHelper != null mDbHelper.isOpen())
Even with that I still get this error:
INFO/dalvikvm(23250): Uncaught exception thrown by finalizer (will be
discarded):
INFO/dalvikvm(23250): Ljava/lang/IllegalStateException;: Finalizing
cursor android.database.sqlite.sqlitecur...@44887dc8 on media that has
not been deactivated or closed
Disregard, I found the issue.
If in your MediaDbAdapter call you get a Cursor check for null
etc..then pass it and close it from another class then the one in
MediaDbAdapter does not get closed, until the system does it for you.
I changed it to pass the cursor directly from the call and deal
3 matches
Mail list logo