如何在Android P(API 28)中使用外部SD卡打开数据库?
代码在这里: Unable to open database in Android Pie (Android 9)
Android P(API 28)对位于外部SD卡中自定义路径中的SQLite数据库文件无效。
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();
我想要一个类似于以下内容的方法:
SQLiteDatabase.openDatabase(custom_path, null,SQLiteDatabase.OPEN_READWRITE)