Accessing SQLite db on Android 11

Viewed 2099

I know public external storage changed from Android 11. But I am not sure where to put my SQLite database and how to access this. Db must not be deleted if app is uninstalled. Other apps must also be able access this SQLite db.

In Android 10 and under I used : Android.OS.Environment.ExternalStorageDirectory.AbsolutePath to get the path to my SQLite db.

How must I adjust this for Android 11?

1 Answers

Android 11 (API level 30) further enhances the platform, giving better protection to app and user data on external storage. This release introduces several enhancements, such as raw file path access, batch edit operations for media, and an updated UI for the Storage Access Framework.

The release also offers improvements to scoped storage, which makes it easier for developers to fulfill their storage use cases after they migrate to using this storage model.

Apps that run on Android 11 but target Android 10 (API level 29) can still request the requestLegacyExternalStorage attribute. This flag allows apps to temporarily opt out of the changes associated with scoped storage, such as granting access to different directories and different types of media files. After you update your app to target Android 11, the system ignores the requestLegacyExternalStorage flag.

For more details,you can check document: https://developer.android.com/about/versions/11/privacy/storage .

Related