android.database.sqlite.SQLiteException: file is not a database (code 26): , while compiling: SELECT COUNT(*) FROM sqlite_schema;

Hay Team,

i am using :

**implementation ("net.zetetic:sqlcipher-android:4.6.0@aar")**

** implementation (“androidx.sqlite:sqlite:2.2.0”)**

if i running my app in my device samsung S10, my app crash and this error android.database.sqlite.SQLiteException: file is not a database (code 26): , while compiling: SELECT COUNT(*) FROM sqlite_schema; , but if i running in other divice or emulator, my app no crash and normal i useed, pliss help i stak because this bug, thanks

this my code :

abstract class QuranDatabase : RoomDatabase() {

    abstract fun quranDataDao(): QuranDataDao

    companion object {
        @Volatile
        private var INSTANCE: QuranDatabase? = null
        private val base64EncodeDbKey: String = BuildConfig.BASE64_KEY_DB

        fun getDatabase(context: Context): QuranDatabase {
            return INSTANCE ?: synchronized(this) {
                val passphrase = base64EncodeDbKey.toByteArray(Charsets.UTF_8)
                val factory = SupportOpenHelperFactory(passphrase)
                val instance = Room.databaseBuilder(
                    context.applicationContext,
                    QuranDatabase::class.java,
                    "quran_database"
                )
                    .openHelperFactory(factory)
                    .createFromAsset("databases/iqra.db")
                    .build()
                INSTANCE = instance
                instance
            }
        }
    }
}

Hi @Ali_Imran,

  • Does this database file already exist?
  • If it exists, is it a SQLCipher-encrypted database, or SQLite plaintext database?
  • If it is a SQLCipher-encrypted database, which version of SQLCipher was used to encrypt it?
  • Are you able to open the database file using an external tool such as DB Browser for SQLite?

yes sir my database already exists, yes I can open it with DB Browser for sql lite, I use SQLCipher 4

this picture setting sqlShiper in my db browser :

but this error occurs only on my Samsung S10 devices, if I run it on the emulator and the Android version is the same, it doesn’t crash

Hi @Ali_Imran,

Can you reproduce this behavior in a small standalone demo application with a sample database which you can share publicly? We would be happy to review that.