Hello forum!
I developed an app that relies on a local sqlite database.
It works almost always but on some random devices i log strange logs/Crashes on Play Developer Console.
The crashes says:
It seems that the database inizialized in starter service has been closed without reason.
Someone on internet says that "you must close your db as soon as you complete your transaction or else your app may throw database object leaked exception if you keep your db open for so long"
(https://stackoverflow.com/questions...lstateexception-attempt-to-re-open-an-already)
Someone else says: "My solution was to catch the exception and re-open the database if needed, and then try the transaction again."
(https://stackoverflow.com/questions...n-an-already-closed-object-what-might-be-clos)
Anyone experienced similar issues and found a solution?
The solution to test if the database is initialized seems a good workaround but i am wondering if there is a more elegant way to keep the database always opened due to the fact it is initialized at startup in starter service.
Thanks in advance for your suggestions
I developed an app that relies on a local sqlite database.
It works almost always but on some random devices i log strange logs/Crashes on Play Developer Console.
The crashes says:
B4X:
java.lang.RuntimeException:
at anywheresoftware.b4a.keywords.Common$13.run (Common.java:1692)
at android.os.Handler.handleCallback (Handler.java:836)
at android.os.Handler.dispatchMessage (Handler.java:103)
at android.os.Looper.loop (Looper.java:203)
at android.app.ActivityThread.main (ActivityThread.java:6251)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1073)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:934)
Caused by: java.lang.IllegalStateException:
at android.database.sqlite.SQLiteClosable.acquireReference (SQLiteClosable.java:55)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:1344)
at android.database.sqlite.SQLiteDatabase.rawQuery (SQLiteDatabase.java:1287)
at anywheresoftware.b4a.sql.SQL.ExecQuery2 (SQL.java:223)
at myproject.me.funzioni._vvvvvvvvvvvv1 (funzioni.java:2507)
at myproject.me.main._settanotifica_numeroconversazioninonlette (main.java:12816)
at myproject.me.main$ResumableSub_Carica_App_LayoutBase.resume (main.java:3915)
at anywheresoftware.b4a.keywords.Common$13.run (Common.java:1690)
It seems that the database inizialized in starter service has been closed without reason.
Someone on internet says that "you must close your db as soon as you complete your transaction or else your app may throw database object leaked exception if you keep your db open for so long"
(https://stackoverflow.com/questions...lstateexception-attempt-to-re-open-an-already)
Someone else says: "My solution was to catch the exception and re-open the database if needed, and then try the transaction again."
(https://stackoverflow.com/questions...n-an-already-closed-object-what-might-be-clos)
Anyone experienced similar issues and found a solution?
The solution to test if the database is initialized seems a good workaround but i am wondering if there is a more elegant way to keep the database always opened due to the fact it is initialized at startup in starter service.
Thanks in advance for your suggestions