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

Fatal Exception: net.sqlcipher.database.SQLiteException file is not a database: , while compiling: select count(*) from sqlite_master; #621

Closed IrfanMalikAndroid closed 1 year ago

IrfanMalikAndroid commented 1 year ago

Fatal Exception: net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master; at net.sqlcipher.database.SQLiteCompiledSql.native_compile() at net.sqlcipher.database.SQLiteCompiledSql.compile(:15) at net.sqlcipher.database.SQLiteCompiledSql.(:30) at net.sqlcipher.database.SQLiteProgram.(:103) at net.sqlcipher.database.SQLiteQuery.() at net.sqlcipher.database.SQLiteDirectCursorDriver.query(:7) at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(:33) at net.sqlcipher.database.SQLiteDatabase.rawQuery(:1) at net.sqlcipher.database.SQLiteDatabase.keyDatabase(:30) at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(:14) at net.sqlcipher.database.SQLiteDatabase.openDatabase(:14) at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(:7) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(:85) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(:9)

sjlombardo commented 1 year ago

This indicates that an incorrect key is being used to open the database file. It is not a defect. Check that the key material matches the key used to create the database. If you have other questions open a thread on the SQLCipher discussion forum: https://discuss.zetetic.net/c/sqlcipher/5

IrfanMalikAndroid commented 1 year ago

I think key using same and cannot get the actual point of crashing, if its version issue then i am using this version implementation "net.zetetic:android-database-sqlcipher:4.5.1"

sjlombardo commented 1 year ago

Did you previously upgrade from an earlier version of SQLCipher?

IrfanMalikAndroid commented 1 year ago

from simple sql to cipher i have updated

sjlombardo commented 1 year ago

@IrfanMalikAndroid In that case, you will need to convert the plaintext database using the procedure described here:

https://discuss.zetetic.net/t/how-to-encrypt-a-plaintext-sqlite-database-to-use-sqlcipher-and-avoid-file-is-encrypted-or-is-not-a-database-errors/868