There is a similar problem,
android.database.sqlite.SQLiteException: Failed to change locale for db Caused by: android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed (code 11)
But my database is created by android through SQLiteOpenHelper. And it appears in a few of devices. I want to know what can cause this problem , since I even can not reproduce it. How can I solve this problem? Thanks a lot!
android.database.sqlite.SQLiteException: Failed to change locale for db '/data/data/com.android.settings/databases/myDB.db' to 'zh_CN'.
at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:386)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:218)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:833)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.example.optimizecenter.packages.e.mO(PackagesManager.java:150)
at com.example.optimizecenter.packages.PackageSyncService.onHandleIntent(PackageSyncService.java:24)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
Caused by: android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed (code 11)
at android.database.sqlite.SQLiteConnection.nativeExecuteForString(Native Method)
at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:634)
at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:367)
... 18 more
Here is my helper class.
public class PackageDataBaseHelper extends SQLiteOpenHelper {
public PackageDataBaseHelper(Context context) {
super(context, PackageColumns.DB_NAME, null, PackageColumns.DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
StringBuilder sb = new StringBuilder();
sb.append("create table ");
sb.append(PackageColumns.TABLE_PACKAGE);
sb.append(" (");
sb.append(PackageColumns._ID + " integer primary key autoincrement, ");
sb.append(PackageColumns.COLUMN_APPLICATION_LABEL + " TEXT ,");
sb.append(PackageColumns.COLUMN_PACKAGE_NAME + " TEXT ,");
sb.append(PackageColumns.COLUMN_VERSION_NAME + " TEXT ,");
sb.append(PackageColumns.COLUMN_VERSION_CODE + " INTEGER ,");
sb.append(PackageColumns.COLUMN_IC_LAUNCHER + " BOLD");
sb.append(");");
db.execSQL(sb.toString());
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// ignore
}
}
SQLiteDatabase db=SQLiteDatabase.openDatabase("/data/data/com.android.settings/databases/myDB.db", null,SQLiteDatabase.NO_LOCALIZED_COLLATORS|SQLiteDatabase.CREATE_IF_NECESSARY);
Try this code sample to your code..
If you have sqlite browser, open your database.. In your database, locale of android_metadata table seem not be en_US