How can i do the following situation for android Q (Api 29)?
My intention is to keep in a directory that will continue to exist after uninstalling the application.
It has the following class with its constructor:
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
}
And in my DAO when calling the database:
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
}
Using SQLiteOpenHelper is there any way to create database in Public Documents folder for Api 29?
Thank you for your attention