Android SQLiteException: Failed to change locale for db to 'en_US' Android SQLiteException: Failed to change locale for db to 'en_US' sqlite sqlite

Android SQLiteException: Failed to change locale for db to 'en_US'


check your database content, specially 'android_metadata'. it's a table with this DDL:

CREATE TABLE android_metadata (     locale TEXT );

which should contain at least one record with this content:

en_US

this solved my own problem.

for more details:
open your database file with a sqlite editor such as SQLiteStudio then open android_metadata table (if it does not exist create it. (you may create it with the query editor (tools>open query editor) and copy/paste the DDL code above)

for inserting the record you may copy/paste this line in the query editor:

insert into android_metadata values ('en_us');

hint: to run the query in SQLiteStudio you should push the button with lightening icon in the toolbar.


The key is android.database.sqlite.SQLiteDatabaseLockedException.

I had the same issue, and it kept increasing with the increase in Database Locking.

What to do? - Eliminate Database locking.

How? - Make sure no concurrent write calls take place, and

You may read more about avoiding database locking here and in this very well explained SO answer.

I would suggest shifting all your write calls on a single thread, this way avoiding locking. You could use AsyncQueryHandler for this.


This doesn't entirely answer the question, but you may also want to check out this article, and see if perhaps you can work this into your DbHelperSingleton, since it seems to be the same error you are facing:

Failed to change locale for db '/data/data/my.easymedi.controller/databases/EasyMediInfo.db' to 'en_US'