Как я могу сделать следующую ситуацию для Android Q (Api 29)?
Я намерен сохранить в каталоге, который будет существовать после удаления приложения.
Он имеетследующий класс с его конструктором:
public class SqlHelper extends SQLiteOpenHelper {
//constructor
SqlHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
//rest of the class
}
И в моем DAO при вызове базы данных:
public class Dao {
private Context context;
protected SQLiteDatabase db;
public Dao(Context context) {
this.context = context;
}
protected void openDataBase() {
String pathDB = FOLDER_NAME_DBASE;
//getExternalStorageDirectory() deprecated Api 29
File dir = new File(Environment.getExternalStorageDirectory(), pathDB);
String dBasePath = dir.getPath() + "/" + mydatabse.db3;
SqlHelper varHelp = new SqlHelper(
context,
dBasePath,
null,
DBASE_VERSION
);
db = varHelp.getWritableDatabase();
}
//rest of the class
}
Используя SQLiteOpenHelper, есть ли способ создать базу данных в папке Public Documents для Api 29?
Спасибо за внимание