web-dev-qa-db-ja.com

既に閉じられているオブジェクトを再度開く試み:SQLiteDatabase

プロジェクトのプロパティでプロジェクトのビルドターゲットを4.1 google APIに変更しようとすると、logcatでこれらのエラーが発生します。プロジェクトのプロパティを修正してプロジェクトをクリーンアップしようとしましたが、成功しませんでした。どうしたの?

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
22
Noctilux

SQLiteDatabaseのインスタンスを1つだけ使用していることを確認してください。あなたは複数のインスタンスをインスタンス化し、Androidが結果として不平を言っていると思います。

この件についても、この ブログ投稿 をご覧ください。

31
Alex Lockwood