I need to open a large SQLite Database on Android 11 (api level 30). The Documentation says that "MANAGE_EXTERNAL_STORAGE" is a Problem in the Future.
Therefore, I read the Docs at: https://developer.android.com/training/data-storage/shared/documents-files and used:
public void openDirectory(Uri uriToLoad) {
// Choose a directory using the system's file picker.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, 42);
}
@Override
public void onActivityResult(int requestCode, int resultCode,
Intent resultData) {
if (requestCode == 42
&& resultCode == Activity.RESULT_OK) {
// The result data contains a URI for the document or directory that
// the user selected.
Uri uri = null;
if (resultData != null) {
uri = resultData.getData();
DocumentFile dfile = DocumentFile.fromTreeUri(this, uri);
DocumentFile[] fileList = dfile.listFiles();
}
}
}
If I understand the Documentation right, File is deprecated or can not be used with Files on the SD Card and DocumentFile/URI is the new thing. But to open the Database I use:
SQLiteDatabase.openDatabase(
pFile.getAbsolutePath(),
null,
SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY))
So my Problem is: How to open a large (10Gb or more) Database with an URI or a DocumentFile.
Ps.: The Database is a RasterLite File with map images