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

无人久伴 提交于 2019-11-29 01:25:17

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

icon in the toolbar.
user2520215

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.

anddev84

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'

If you're changing your locale in the app, make sure you change it before you open your database.

I was having this same issue in my app when I was switching the locale after opening my database, and it was trying to switch to a different database based on the locale, which didn't exist.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!