-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqfliteDatabaseException DatabaseException(open_failed /var/mobile/Containers/Data/Application/.../Documents/database_name.db) #99
Comments
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? |
@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. |
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 |
@davidmartos96 Actually I have run "PRAGMA cipher_version" and it prints successfully "SQLCipher Version: 4.5.7 community". |
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 |
@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 |
I'm encountering the same error. |
@marijam26 would you be able to create a reproduction demo app? |
@davidmartos96 Also still facing it, this is totally random so unfortunately I can't show a demo for it. Nearly I have tried everything to catch the scenario for this but as mentioned, it is random. |
I have same issue. Using this code:
When running same Flutter app on Macos it runs properly I can open passworded sqlite file. When running on Android with same code (same password) and same sqlite file it crashes on above function.
|
@nrsimha What iOS version has the device that fails? |
@davidmartos96 It has not iOS version as it is Android 13 device. Didn't try on iOS yet. |
@nrsimha Sorry, I thought this was iOS only. What do you get after running this? #99 (comment) Without a reproduction example/project I cannot see what could be wrong. |
Running on both Android and Macos I am getting this result:
I run this code to test it:
|
I tried to make minimal project with example and it works on Android now. |
@nrsimha Does the destination file parent folder exist before calling open? |
@davidmartos96 Issue is somehow related to conflicting with sqflite. When user select file it first try to open it with sqflite:
For some reason it crashes on Android when I try to run If I try first to open with password it opens nicely. |
@nrsimha Interesting, are you able to reproduce it in the demo you were building? |
Yes, it is definitely caused by trying to open that file with sqflite opening as when I checked filesize before it was 328MB and after that it was 12kB. So it somehow deleted whole database and when I tried to open it with sqflite_sqlcipher it crashed as file was damaged. |
In demo was working as I tried to open file only through sqflite_sqlcipher. Fix was to set So my issue was not caused by sqflite_sqlcipher, but by sqflite. Thank you for sqflite_sqlcipher and your quick responses! |
@nrsimha Just so you know, sqlcipher is compatible with regular sqlite if you provide an empty password. |
Cool! Didn't know that. It makes my code cleaner. Still need to use readonly for testing though, but that is not a problem. |
I'm facing this on the latest version
SqfliteDatabaseException DatabaseException(open_failed/var/mobile/Containers/Data/Application/.../Documents/database_name.db)
The text was updated successfully, but these errors were encountered: