sys error "Finalizing a Cursor that has not been deactivated or closed."

peacemaker

Expert
Licensed User
Longtime User
Hi, all

I try to show a preselected text info on a new activity.

1) First time all works OK, but if to press BACK and again try to StartActivity with this info - StartActivity does not work, but code before is OK.
2) No error in the filtered logcat.
3) If to go BACK to the previous activity, and go again to this code - again one time activity is opened OK. But again only once.
4) If to unfilter the log - the error can be seen, but only in in Android 2.2 (!), the same code does not give any error under Android 2.3.

Error is:

B4X:
Finalizing a Cursor that has not been deactivated or closed. database = /mnt/sdcard/Android/data/peacemaker.mobilecourier/files/mcdb.s3db, table = null, query = SELECT     messagenumber,     messagedatetime,     messages.usercode, .......

android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here

What does it mean ? SQLite DB is always open, no other error at using SQLite.
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
getString FLEX_OPERATOR_CODE OPEN
** Activity (messages) Resume **
[android_net_wifi_getRssiHelper] rssi -54
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44ec1320
Starting activity: Intent { flg=0x20000 cmp=peacemaker.mobilecourier/.docdetailedview }
** Activity (messages) Pause, UserClosed = false **
** Activity (docdetailedview) Create, isFirst = false **
** Activity (docdetailedview) Resume **
Displayed activity peacemaker.mobilecourier/.docdetailedview: 339 ms (total 339 ms)
** Activity (docdetailedview) Pause, UserClosed = true **
** Activity (messages) Resume **
Finalizing a Cursor that has not been deactivated or closed. database = /mnt/sdcard/Android/data/peacemaker.mobilecourier/files/mcdb.s3db, table = null, query = SELECT messagenumber, messagedatetime, messages.usercode, users.fio AS fio, mess
android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:210)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:107)
at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:95)
at peacemaker.mobilecourier.messages._th_tabchanged(messages.java:694)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.objects.TabHostWrapper$1.onTabChanged(TabHostWrapper.java:52)
at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:378)
at android.widget.TabHost.setCurrentTab(TabHost.java:363)
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:138)
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:453)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
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)
Finalizing a Cursor that has not been deactivated or closed. database = /mnt/sdcard/Android/data/peacemaker.mobilecourier/files/mcdb.s3db, table = null, query = SELECT messagenumber, messagedatetime, messages.usercode, users.fio AS fio, mess
android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:210)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:107)


Closing the cursor - i avoided this error.
But actually problem exists anyway - StartActivity works only once. New try - it does not work:

 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Problem is in the sub :


Where StartActivity("DocDetailedView") works only one time.
If to go back from "DocDetailedView" - tapping lblMessages again does not open "DocDetailedView".
And unfiltered log gives at tapping:
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$ Proxy@44afca28

I guess this view mentioned is the Sender, one among lblMessages.
These labels were created programmatically on a ScrollView, according to a recordset.

If to go BACK more and again open Messages activity - StartActivity("DocDetailedView") works ones again.
--------------------
And the main - no this problem, if i create labels according to a recordset by loading from a layout file to programmatically created ScrollViews.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I thought that this cursor error relevant, this error seemed to be at returning BACK from "DocDetailedView" to "Messages". But real problem is in Sub lblMessages_Click.

So thread name is irrelevant now :-(
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes ! Exactly this problem.
Thanks, will try timer.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…