How to openDatabase at external SD card in Android P (API 28)?
The code is over here : Unable to open database in Android Pie (Android 9)
The Android P(API 28) is not valid for SQLite Database files that are located in a custom path in external SD card.
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
MySQLiteOpenHelper helper = new MySQLiteOpenHelper();
SQLiteDatabase database = helper.getReadableDatabase();
myPath = database.getPath();
} else {
String DB_PATH = Environment.getDataDirectory() + "/data/my.trial.app/databases/";
myPath = DB_PATH + dbName;
}
checkDB=SQLiteDatabase.openDatabase(myPath,null,
SQLiteDatabase.OPEN_READWRITE);
checkDB.disableWriteAheadLogging();
I want a method that is similar to:
SQLiteDatabase.openDatabase(custom_path, null,SQLiteDatabase.OPEN_READWRITE)