In my android app I ve got the below code creating my database. This works no problem, but directly after this code is executed I attempt to getReadableDatabase() and it says the database is locked throwing an exception
Do I need to close / destory anything here to keep it from being locked? Thank you!
//this is done to see if it s created yet
private boolean checkDataBase() {
SQLiteDatabase checkDB = null;
try {
String myPath = "/data/data/com.hats.android/databases/";
checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
} catch (SQLiteException e) {
//database does t exist yet.
}
if (checkDB != null) {
checkDB.close();
}
return checkDB != null ? true : false;
}
//then the below is done to create it (following this is the getReadableDatabase() error)
@Override
public void onCreate(SQLiteDatabase db) {
SQLiteDatabase checkDB = null;
String myPath = "/data/data/com.hats.android/databases/";
checkDB = this.myContext.openOrCreateDatabase(myPath, SQLiteDatabase.CREATE_IF_NECESSARY, null);
checkDB.execSQL("CREATE TABLE hats (hat_id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT)");
checkDB.close();
}