尝试重新打开一个已经关闭的对象:SQLiteDatabase
当我尝试在Project Properties中将项目构建目标更改为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
回答:
确保您仅使用的一个实例SQLiteDatabase
。我猜想您实例化了多个实例,结果Android抱怨了。
您也应该查看有关此主题的
。
以上是 尝试重新打开一个已经关闭的对象:SQLiteDatabase 的全部内容, 来源链接: utcz.com/qa/418139.html