davidmartos96 / sqflite_sqlcipher

SQLite flutter plugin
BSD 2-Clause "Simplified" License
102 stars 46 forks source link

SqfliteDatabaseException DatabaseException(open_failed /var/mobile/Containers/Data/Application/.../Documents/database_name.db) #99

Open amrLLSE opened 1 month ago

amrLLSE commented 1 month ago

I'm facing this on the latest version SqfliteDatabaseException DatabaseException(open_failed/var/mobile/Containers/Data/Application/.../Documents/database_name.db)

davidmartos96 commented 1 month ago

That can happen when you are providing the wrong password to an encrypted database. Are you opening a database bundled in the app assets or are you encrypting a fresh database?

amrLLSE commented 1 month ago

@davidmartos96 Fresh database, but I'm sure 100% that the password is correct. Now I'm also investigating in this and if I have reached to the root cause I will mention it here. But if you have any other ideas why this may happen just let me know.

davidmartos96 commented 1 month ago

I would double check if you have sqlcipher correctly installed. You can open a memory database with sqflite without password and then run "PRAGMA cipher_version" on the database. You should see SQLCipher and the version number. If you don't, it means that something is not correctly configured

amrLLSE commented 1 month ago

@davidmartos96 Actually I have run "PRAGMA cipher_version" and it prints successfully "SQLCipher Version: 4.5.7 community".

davidmartos96 commented 1 month ago

In that case I can only think the following:

I'd try deleting the file in the device and try fresh with your latest code. Maybe it was previously encrypted with a different password.

You can also check the SQLCipher related tests (in the lib folder) in the example app in the repository

amrLLSE commented 1 month ago

@davidmartos96 Okay will check, but this plugin is always using 4x version and I didn't use anything else to open the database.

Thanks for you quick replies and support