-
-
Notifications
You must be signed in to change notification settings - Fork 527
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
[Android] attempt to write a readonly database #1137
Comments
sqflite on iOS and Android uses whatever SQLite bundled on the platform. It seems the UPSERT (ON CONFLICT) feature was added in SQLite 3.24 which might not be present in some Android version: See
You can do a "SELECT sqlite_version()" to check the version. I see 2 solutions:
|
Forget that, I see the report is on Android 14 which should be fine. Parallel writes should be fine. sqflite serializes calls anyway. Still puzzled...my only "feeling" would be not to use the cache directory but instead use getDatabasesPath on Android and manage on your side to not make it too big. I don't know what is the Android behavior as when the cache is cleared (low storage situation, mabye your database is very big) but indeed if Android decides to delete the files, the error reported might happen. One alternative solution would be to catch this error and re-open the database when it happens. I'll try later (not very soon) to reproduce the issue by filling a db on the cache or by forcing file deletion but so far sqlite does not provide any automatic mechanism to handle this issue. |
Do you confirm that you create the directory before opening the database ? (there is a missing await for dbDirectory.create in some code you posted above) |
Wow 🤩, I should look for a linter check to enforce explicitly use |
|
Thanks for your point. I close the issue for now. if I face the error again, will let you know. but based on your point it should resolve the error. |
as I said above, one reason could be the usage of the application cache directory that Android might cleanup this folder at any time. Can you try using |
Hi,
I use sqflite to cache network responses, and delete the expired caches weekly.
After publishing the app, I got below crash reports in Firebase for some Android devices:
Here is how I create the db:
I don't delete the db file after creation.
Do you think it can be result of parallel writes in the same table?
The text was updated successfully, but these errors were encountered: