maskarade/Android-Orma

Application did not close the cursor or database object that was opened here (net.sqlcipher.database.DatabaseObjectNotClosedException)

Closed this issue · 8 comments

i am getting these with 5.0.0-rc1 with encrypted database when i exit my app

###/com.zoffcc.applications.trifa E/Database: close() was never explicitly called on database '/data/user/0/xxxxxx/xxxx.db' 
net.sqlcipher.database.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
    at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:2402)
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1148)
    at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1203)
    at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1198)
    at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1183)
    at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1219)
    at com.github.gfx.android.orma.encryption.EncryptedDatabase$Provider.provideOnDiskDatabase(EncryptedDatabase.java:170)
    at com.github.gfx.android.orma.OrmaConnection.openDatabase(OrmaConnection.java:106)
    at com.github.gfx.android.orma.OrmaConnection.<init>(OrmaConnection.java:96)
    at com.zoffcc.applications.trifa.OrmaDatabase$Builder.build(OrmaDatabase.java:466)
    at com.zoffcc.applications.trifa.MainActivity.onCreate(MainActivity.java:395)
    at android.app.Activity.performCreate(Activity.java:6681)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2651)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2765)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1506)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:153)
    at android.app.ActivityThread.main(ActivityThread.java:6234)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
gfx commented

This is the spec. Keep the database connection as a global, singleton instance.

It is not intended that you connect the DB for each time in use.

However, if you really know what you are doing, OrmaConnection#close() is provied in v5.0.0-rc3.

i do not connect again. it just crashes often with this error. and after that the database table is corrupt and app can never start again.
the DB is defined as static in a Forgroundservice

gfx commented

Oh, really?

Should be investigated more deeply.

Can you tell me more information about it? Do you have a minimum re-producable code?

i have now switched back to 4.x without encryption

gfx commented

I guess this is a bug in SQLCipher. I have no idea about it.

I am facing a similar issue, Does someone found any solutions?

gfx commented

Please issue it to SQLCipher's issue tracker. I think it's the SQLCipher's problem.

This is especially happening for delete queries