My code to create a database in the application class file works on many thousands of devices, but recently I got a multiple crash from android 6.0, so it can be associated with the new version of Android. Also, this crash was seen only lower than the three devices. Please advise how to fix this.
Devices: Canvas A1 (AQ4501_sprout), Dream Uno (Mi-498_sprout), Sparkle V (Sparkle_V_sprout)
Crash Log:
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
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:571)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:269)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
Link Code (Crash happens in db.getWritableDatabase ()):
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
dataBaseInit();
}
private void dataBaseInit() {
db = new MyDatabase(getApplicationContext());
dataBaseRef = db.getWritableDatabase();
}
}
public class MyDatabase extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "myDatabase";
public MyDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
}
A crash occurs on db.getWritableDatabase ().
Please advise how to fix this.
source
share