How can I change an SQLite database from read-only to read-write?
When I executed the update statement, I always got:
SQL error: attempt to write a readonly database
The SQLite file is a writeable file on the filesystem.
How can I change an SQLite database from read-only to read-write?
When I executed the update statement, I always got:
SQL error: attempt to write a readonly database
The SQLite file is a writeable file on the filesystem.
In Linux command shell, I did:
Where contains the database file.
It works. Now I can access my database and make insert queries.
To share personal experience I encountered with this error that eventually fix both. Might not necessarily be related to your issue but it appears this error is so generic that it can be attributed to gazillion things.
Database instance open in another application. My DB appeared to have been in a "locked" state so it transition to read only mode. I was able to track it down by stopping the a 2nd instance of the application sharing the DB.
Directory tree permission - please be sure to ensure user account has permission not just at the file level but at the entire upper directory level all the way to / level.
Thanks
I solved this by changing owner from root to me on all files on /db dir.
Just do
ls -l
on that folder, if any of the filer is owned byroot
just change it to you, using:sudo chown user file
If using Android.
Make sure you have added the permission to write to your
EXTERNAL_STORAGE
to yourAndroidManifest.xml
.Add this line to your
AndroidManifest.xml
file above and outside your<application>
tag.This will allow your application to write to the sdcard. This will help if your
EXTERNAL_STORAGE
is where you have stored your database on the device.This error usually happens when your database is accessed by one application already, and you're trying to access it with another database.
From the command line, enter the folder where your database file is located and execute the following command:
This will grant all permissions to all users.