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

android.database.sqlite.SQLiteException: SQL logic error: , while compiling: select count(*) from sqlite_master; #626

Closed Android1500 closed 1 year ago

Android1500 commented 1 year ago

After adding factory to room db i got this error i am not sure why i getting error even i tried :-

`private fun getSupportFactory(): SupportFactory { val passPhrase: ByteArray = SQLiteDatabase.getBytes(passphrase.toCharArray()) val hook = object : SQLiteDatabaseHook { override fun preKey(database: SQLiteDatabase?) {}

    override fun postKey(database: SQLiteDatabase?) {
        database?.rawExecSQL("PRAGMA key = '$passPhrase';")
        database?.rawExecSQL("PRAGMA cipher_migrate;")
    }
}
return SupportFactory(passPhrase, hook)

}`

room builder :- fun getRoomDatabase(context: Context) = Room.databaseBuilder( context, AndroidFakerRoomDatabase::class.java, DATABASE_NAME ).openHelperFactory(getSupportFactory()) .createFromAsset("databases/database.db") .build()

Android1500 commented 1 year ago

After some research i found that its cause of using createFromAsset()