开发者

finalizing cursor that has not been deactivate or closed

all

      i am working on one application in which i have to used database.

In that i used static cursor and return the cursor.in onDestroye() i am closing the cursor but my question is that i am using cursor as a static so problem is that when i run the application and use cursor first time it not show me the error but accessing a cursor second time it shows the error like this :

Finalizing a Cursor that has not been deactivated or closed. database = /data/data/com.technosoft.listia/databases/Listia, table = null, query = select * from Browser where id=2
07-20 12:37:02.292: ERROR/Cursor(588): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
07-20 12:37:02.292: ERROR/Cursor(588): at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:210)
07-20 12:37:02.292: ERROR/Cursor(588): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53)
07-20 12:37:02.292: ERROR/Cursor(588): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
07-20 12:37:02.292: ERROR/Cursor(588): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
07-20 12:37:02.292: ERROR/Cursor(588): at com.technosoft.listia.DataBaseListia.SelectBrosertab(DataBaseListia.java:103)
07-20 12:37:02.292: ERROR/Cursor(588): at com开发者_StackOverflow.technosoft.browserTab.BrowserCategoryList.ListviewDisplayMrthod(BrowserCategoryList.java:356)
07-20 12:37:02.292: ERROR/Cursor(588): at com.technosoft.browserTab.BrowserCategoryList$1.handleMessage(BrowserCategoryList.java:347)
07-20 12:37:02.292: ERROR/Cursor(588): at android.os.Handler.dispatchMessage(Handler.java:99)
07-20 12:37:02.292: ERROR/Cursor(588): at android.os.Looper.loop(Looper.java:123)
07-20 12:37:02.292: ERROR/Cursor(588): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-20 12:37:02.292: ERROR/Cursor(588): at java.lang.reflect.Method.invokeNative(Native Method)
07-20 12:37:02.292: ERROR/Cursor(588): at java.lang.reflect.Method.invoke(Method.java:521)
07-20 12:37:02.292: ERROR/Cursor(588): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-20 12:37:02.292: ERROR/Cursor(588): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-20 12:37:02.292: ERROR/Cursor(588): at dalvik.system.NativeStart.main(Native Method)

how can i get rid from this... please help me as early as possibe

Thank you......


when you start your application its start with the oncreate method and as you declare the cursor as static so when you back the onDestroy method was invoked and cursor was closed.

now second time it start with the onResume method so at that time the cursor was closed so at query time it will not open you need to open that cursor again.

to maintain that cursor call this startManagingCursor(Cursor object) after initialize the cursor so it will manage by the application you don't need to explicitly close the cursor

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜