Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

attempt to re-open an already-closed object: SQLiteDatabase

Tags:

I get these errors in my logcat when i tried to change my project build target to 4.1 google API, in Project Properties. I've tried to fix project properties and clean project, but with no success. What's the problem?

10-07 15:13:34.839: E/Trace(731): error opening trace file: No such file or directory (2) 10-07 15:13:35.259: I/SQLiteConnectionPool(731): The connection pool for /data/data/hr.punctum.LociranjePonudaProizvoda/databases/proizvodidb has been closed but there are still 1 connections in use.  They will be closed as they are released back to the pool. 10-07 15:13:35.259: D/AndroidRuntime(731): Shutting down VM 10-07 15:13:35.259: W/dalvikvm(731): threadid=1: thread exiting with uncaught exception (group=0x40a13300) 10-07 15:13:35.278: E/AndroidRuntime(731): FATAL EXCEPTION: main 10-07 15:13:35.278: E/AndroidRuntime(731): java.lang.RuntimeException: Unable to start activity ComponentInfo{hr.punctum.LociranjePonudaProizvoda/hr.punctum.LociranjePonudaProizvoda.ListaProizvoda}: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/hr.punctum.LociranjePonudaProizvoda/databases/proizvodidb 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.ActivityThread.access$600(ActivityThread.java:130) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.os.Handler.dispatchMessage(Handler.java:99) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.os.Looper.loop(Looper.java:137) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.ActivityThread.main(ActivityThread.java:4745) 10-07 15:13:35.278: E/AndroidRuntime(731):  at java.lang.reflect.Method.invokeNative(Native Method) 10-07 15:13:35.278: E/AndroidRuntime(731):  at java.lang.reflect.Method.invoke(Method.java:511) 10-07 15:13:35.278: E/AndroidRuntime(731):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 10-07 15:13:35.278: E/AndroidRuntime(731):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-07 15:13:35.278: E/AndroidRuntime(731):  at dalvik.system.NativeStart.main(Native Method) 10-07 15:13:35.278: E/AndroidRuntime(731): Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/hr.punctum.LociranjePonudaProizvoda/databases/proizvodidb 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:520) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:263) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164) 10-07 15:13:35.278: E/AndroidRuntime(731):  at hr.punctum.LociranjePonudaProizvoda.ListaProizvoda.onCreate(ListaProizvoda.java:27) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.Activity.performCreate(Activity.java:5008) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 10-07 15:13:35.278: E/AndroidRuntime(731):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 10-07 15:13:35.278: E/AndroidRuntime(731):  ... 11 more 
like image 949
Noctilux Avatar asked Oct 07 '12 15:10

Noctilux


1 Answers

Make sure you are only ever working with one instance of SQLiteDatabase. I'm guessing that you have instantiated multiple instances and Android is complaining as a result.

You should take a look at this blog post on the subject too.

like image 116
Alex Lockwood Avatar answered Sep 30 '22 06:09

Alex Lockwood