开发者

SQLite Exception in android

hi my application contains SQLite .My application some time getting the following error

java.lang.RuntimeException: Unable to destroy activity {com.fitzsoftware.grocessaryList/com.fitzsoftware.grocessaryList.GrocessaryList}: android.database.sqlite.SQLiteException: unable to close due to unfinalised statements
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3655)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3673)
at android.app.ActivityThread.access$2900(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: unable to close due to unfinalised statements
at android.database.sqlite.SQLiteDatabase.dbclose(Native Method)
at android.database.sqlite.SQLiteDatabase.onAllReferencesReleased(SQLiteDatabase.java:320)
at androi开发者_JS百科d.database.sqlite.SQLiteDatabase.close(SQLiteDatabase.java:881)
at com.fitzsoftware.grocessaryList.GrocessaryList.onDestroy(GrocessaryList.java:103)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3642)

I am closing the db in Destroy() using DataClass.dh.db.close(); Why this Error occured.Give me the solutions for this.Thanks in advance.


I'm late to the party, but I just saw this. In my case, I had created a Cursor object from a database query, then accidentally closed the database before I closed the cursor. Check whether this is what's happening.


As well Gareth Lloyd's answer, from what I've read of other threads, another cause of this exception is not closing Cursor objects, i.e. attempting to close your SQLiteDatabase instance before closing Cursor objects that have been obtained from querying your SQLiteDatabase instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜