Fatal Exception: android.database.sqlite.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
UKMIITB opened this issue ยท 4 comments
Fatal Exception: android.database.sqlite.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
at net.sqlcipher.database.SQLiteCompiledSql.native_compile(SQLiteCompiledSql.java)
at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:89)
at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62)
at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:91)
at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:50)
at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:60)
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:2019)
at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1905)
at net.sqlcipher.database.SQLiteDatabase.keyDatabase(SQLiteDatabase.java:2672)
at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:2602)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1250)
at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1325)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:167)
at net.sqlcipher.database.SupportHelper.getWritableDatabase(SupportHelper.java:83)
In a new update. Added sqlCipher for new database file.
implementation "net.zetetic:android-database-sqlcipher:4.5.4"
Implementation wise, I generate one passphrase & save in shared preference permanently.
Then using hilt, initialise database as
Room.databaseBuilder(
context,
EncryptedDatabase::class.java,
ENCRYPTED_DATABASE_NAME
)
.openHelperFactory(SupportFactory(passphrase))
.build()
Till now got one crash in Android 5, OPPO device
Hi @UKMIITB,
It is difficult to say what the root cause of your situation is given the information. This error is common and suggests that SQLCipher for Android was not able to decrypt a file path provided with the supplied password. A few follow-up questions:
- Have you confirmed your application is invoking
SQLiteDatabase.loadLibs(...)
prior to attempt to interface with Room? - Does the database file already exist?
- Is the database file already encrypted with SQLCipher?
- Are you able to access the database content via SQLCipher for Android without the use of hilt?
- Are you able to access the database content via Room with SQLCipher, but without the use of hilt?
This can happen if you are using the wrong/a different passphrase when re-opening the db.
@dazza5000
Your comment is right.
I tried to reinstall my Android app with SQLCipher enabled, it worked. ๐๐ผ
Thanks.
Thanks for confirming that was the problem. Closing this now.