sqlcipher / android-database-sqlcipher

Android SQLite API based on SQLCipher
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
Other
2.73k stars 564 forks source link

close() was never explicitly called on database when calling clearApplicationUserData #570

Closed selmanon closed 2 years ago

selmanon commented 2 years ago

Expected Behavior

No crash

Actual Behavior

The application crash

Steps to Reproduce

(requireContext().getSystemService(ACTIVITY_SERVICE) as ActivityManager).clearApplicationUserData()

SQLCipher version (can be identified by executing PRAGMA cipher_version;):

SQLCipher for Android version: 4.4.3

Logs

fr.bouyguestelecom.ecm.android is my internet provider and not the package name of my application.

2021-10-01 14:40:58.653 5329-5343/? E/Database: close() was never explicitly called on database '/data/user/0/**fr.bouyguestelecom.ecm.android**/databases/messages.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:24) at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:7) at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:6) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:13) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:1) at com.v3d.equalcore.internal.t.b.a.b(CipherSQLiteOpenHelper.java:9) at com.v3d.equalcore.internal.t.e.e.a.<init>(MessageDataBaseHelper.java:3) at com.v3d.equalcore.internal.t.d.a.<init>(DataBaseManager.java:6) at com.v3d.equalcore.a.b.d.<init>(ProxyRegistry.java:11) at com.v3d.equalcore.a.b.b.<init>(ManagerSingleton.java:7) at com.v3d.equalcore.a.b.b.a(ManagerSingleton.java:4) at com.v3d.equalcore.external.bootstrap.EQualOneApiClient.connect(EQualOneApiClient.java:2) at com.v3d.equalcore.external.bootstrap.EQApplication.onCreate(EQApplication.java:16) at fr.bouyguestelecom.ecm.android.EcmApplication.onCreate(EcmApplication.java:1) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190) at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7184) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7134) at android.app.ActivityThread.access$1600(ActivityThread.java:274) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2102) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

developernotes commented 2 years ago

Hi @selmanon

That appears to be log output from a debug build when the finalizer is invoked with an open connection to the database. You should close your existing connection before performing the clearApplicationUserData() operation. The behavior you are seeing would be expected with an open connection.

selmanon commented 2 years ago

hey @developernotes, thank you for your quick reply. I would like to know why this crash is happening against the database of my internet provider company 🤔?

developernotes commented 2 years ago

Hi @selmanon

That is a question you should direct to your Internet service provider, unfortunately. It is likely due to their usage of the library within the application.

selmanon commented 2 years ago

it's not a crash but it's the normal behavior (but not documented again thanks Google)