I go through all the link regarding this issue, but not able to get any clue on that. The exception report I got is from Google Developer Console. I tried the code to in Nexus 4 Device, its working fine.
Below is my stack trace & Code. Can anyone found why the exception is happening.
Stack Trace
Fatal Exception: android.database.sqlite.SQLiteException: Failed to change locale for db '/data/data/in.plackal.lovecyclesfree/databases/LoveCycles.db' to 'en_US'.
at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:399)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:224)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:199)
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:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1167)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:268)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at in.plackal.lovecyclesfree.database.DatabaseOperations.open(DatabaseOperations.java:85)
at in.plackal.lovecyclesfree.general.CycleManager.readSettings(CycleManager.java:7724)
at in.plackal.lovecyclesfree.applicationwidget.WidgetTodayService.getValueFromCycleManager(WidgetTodayService.java:51)
at in.plackal.lovecyclesfree.applicationwidget.WidgetTodayService.onHandleIntent(WidgetTodayService.java:37)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5)
at android.database.sqlite.SQLiteConnection.nativeExecute(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:561)
at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:390)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:224)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:199)
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:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1167)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:268)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at in.plackal.lovecyclesfree.database.DatabaseOperations.open(DatabaseOperations.java:85)
at in.plackal.lovecyclesfree.general.CycleManager.readSettings(CycleManager.java:7724)
at in.plackal.lovecyclesfree.applicationwidget.WidgetTodayService.getValueFromCycleManager(WidgetTodayService.java:51)
at in.plackal.lovecyclesfree.applicationwidget.WidgetTodayService.onHandleIntent(WidgetTodayService.java:37)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:61)
Code Used
public class DatabaseOperations
{
private Context m_Context;
private DataBaseWrapper dbHelper;
private SQLiteDatabase database;
public DatabaseOperations(Context context)
{
m_Context = context;
dbHelper = new DataBaseWrapper(context);
}
public void open() throws SQLException
{
database = dbHelper.getWritableDatabase();
}
public void close()
{
dbHelper.close();
}
}
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DataBaseWrapper extends SQLiteOpenHelper
{
// Database Name
private static final String DATABASE_NAME = "TestDB.db";
// Database Version
private static final int DATABASE_VERSION = 2;
public DataBaseWrapper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db)
{
db.execSQL(CREATE_CYCLE_TABLE);
db.execSQL(CREATE_NOTES_TABLE);
db.execSQL(CREATE_SETTINGS_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
}
@Override
public void onOpen(SQLiteDatabase db)
{
super.onOpen(db);
}
}