Can you help my?
I have created and published the app on Google play store that contains a database, I have tested it on different android phones. My app works perfect on android version (Android 10,8,5 etc...) except on Android 9, do you know how can I fix that problem? I find that problem on Huawei Smart Z, Honor P20, Samsung Y6,Xiaomi Mi. Play store console says that my app can run on that models. I am beginner in app development.
This happening on mine Huawei Smart: when I install the app it opens and crashes when I want to enter in database, and when I want to enter in app again it crashes and on logcat:
E/Path 1: data/data/com.gema/databases/
E/SQLiteLog: (14) cannot open file at line 36906 of [c255889bd9]
E/SQLiteLog: (14) os_unix.c:36906: (2) open(//data/data/com.gematranslate/databases/gema_recnik.db) -
E/SQLiteDatabase: Failed to open database 'data/data/com.gematranslate/databases/gema_recnik.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (Sqlite code 14 SQLITE_CANTOPEN): Could not open database, (OS error - 2:No such file or directory)
In android manifest I put:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
This is my code for check db:
public boolean checkDataBase() {
SQLiteDatabase checkDB = null;
try {
String myPath = DB_PATH + DB_NAME;
checkDB = SQLiteDatabase.openDatabase(myPath,null,SQLiteDatabase.OPEN_READONLY);
myContext.getDatabasePath(DB_NAME).getPath();
checkDB.disableWriteAheadLogging();
} catch (SQLException e)
{
//
}
if (checkDB!= null){
checkDB.close();
}
return checkDB != null? true : false;
This is my code for opening db:
public void openDataBase() {
String myPath = DB_PATH + DB_NAME;
myContext.getDatabasePath(DB_NAME).getPath();
db = SQLiteDatabase.openDatabase(myPath,null, SQLiteDatabase.OPEN_READWRITE);
db.disableWriteAheadLogging();
If anyone can help me, thanks a lot.
This is a solution that is supported on all versions of Android
}