[android-developers] Re: SQLiteCursor on that has not been deactivated or closed
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()) { mDbHelper.close(); } On Jun 17, 10:31 pm, gcstang gcst...@gmail.com wrote: I've followed the try/finally approach but still get this error. Is there anything else that can be done? Here is what I have. MediaDbAdapter mDbHelper = null; Cursor c = null; try { mDbHelper = new MediaDbAdapter(ctxt); mDbHelper.open(); c = mDbHelper.findByX(data.getX()); if(c != null) { //Do an Update on the database } else if(c == null) { //Do an Insert on the database }} finally { if(c != null) { c.deactivate(); c.close(); c = null; } if(mDbHelper != null mDbHelper.isOpen()) { mDbHelper.close(); } } -- 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
[android-developers] Re: SQLiteCursor on that has not been deactivated or closed
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 INFO/dalvikvm(23250): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596) INFO/dalvikvm(23250): at dalvik.system.NativeStart.run(Native Method) I don't know how to get rid of this, I've looked everywhere I can think of for a solution. On Jun 18, 3:44 am, Moss b.thax@gmail.com wrote: 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()) { mDbHelper.close(); } On Jun 17, 10:31 pm, gcstang gcst...@gmail.com wrote: I've followed the try/finally approach but still get this error. Is there anything else that can be done? Here is what I have. MediaDbAdapter mDbHelper = null; Cursor c = null; try { mDbHelper = new MediaDbAdapter(ctxt); mDbHelper.open(); c = mDbHelper.findByX(data.getX()); if(c != null) { //Do an Update on the database } else if(c == null) { //Do an Insert on the database }} finally { if(c != null) { c.deactivate(); c.close(); c = null; } if(mDbHelper != null mDbHelper.isOpen()) { mDbHelper.close(); } } -- 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
[android-developers] Re: SQLiteCursor on 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 with it in the class that called it instead and it worked, no more errors. On Jun 18, 8:43 am, gcstang gcst...@gmail.com wrote: 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 INFO/dalvikvm(23250): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596) INFO/dalvikvm(23250): at dalvik.system.NativeStart.run(Native Method) I don't know how to get rid of this, I've looked everywhere I can think of for a solution. On Jun 18, 3:44 am, Moss b.thax@gmail.com wrote: 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()) { mDbHelper.close(); } On Jun 17, 10:31 pm, gcstang gcst...@gmail.com wrote: I've followed the try/finally approach but still get this error. Is there anything else that can be done? Here is what I have. MediaDbAdapter mDbHelper = null; Cursor c = null; try { mDbHelper = new MediaDbAdapter(ctxt); mDbHelper.open(); c = mDbHelper.findByX(data.getX()); if(c != null) { //Do an Update on the database } else if(c == null) { //Do an Insert on the database }} finally { if(c != null) { c.deactivate(); c.close(); c = null; } if(mDbHelper != null mDbHelper.isOpen()) { mDbHelper.close(); } } -- 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