SQLiteDatabase Access / API 30

91 Views Asked by At

I'd like to update an app on Google Play, and I believe the app must target API level 30 in order to be updated.

The app reads and writes documents, which are actually SQLiteDatabase instances. These documents are stored on the SD card, or in internal storage.

Current version of the app: https://github.com/EricTerrell/Vault3.Android

Currently, the app targets API level 29 and relies on the requestLegacyExternalStorage="true" setting. Additionally it asserts the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions:

https://github.com/EricTerrell/Vault3.Android/blob/main/app/src/main/AndroidManifest.xml#L7-L16

I experimented with using the ACTION_OPEN_DOCUMENT_TREE and ACTION_OPEN_DOCUMENT UIs to specify the folder for the documents, and to open a given document.

My problem is that these UIs return a Uri, not a file path. I don't know if an app can open an SQLiteDatabase database using a file Uri, rather than a path.

I read several posts about how to convert a Uri to a file path. I didn't find anything conclusive. It seems that Google is trying to keep file Uris opaque.

Also, I did not find a way to open an SQLiteDatabase given a file Uri:

https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase?hl=en

The documents are read and written by a desktop app, as well as the Android mobile app, so the file format really can't change.

Any advice is most welcome! If there's a way to open SQLiteDatabases given a file Uri, that would solve my problem.

Eric Bergman-Terrell

https://www.ericbt.com

https://github.com/EricTerrell

0

There are 0 best solutions below