Scoped Storage migration for apps targeting API 30
0 reputation · 13 Dec 2022, 12:48 UTC
Transitioning to MediaStore API
Android 11 enforces scoped storage by default, restricting direct access to external file paths for applications targeting API 30. While the requestLegacyExternalStorage flag provides a temporary bridge for legacy file access, this attribute is ignored on Android 13 and later versions.
The goal is to migrate a small application from direct java.io.File path access to the MediaStore API to ensure long-term compatibility without introducing downtime or runtime crashes on newer OS versions.
There is uncertainty regarding the optimal transition window for apps that must maintain support for Android 10 while preparing for the strict enforcement in Android 13. Specifically, relying on the legacy flag may delay the necessary refactoring of third-party libraries that expect absolute file paths.
- Should the
requestLegacyExternalStorageflag be maintained as a grace period, or is immediate refactoring to content URIs required to prevent failures on Android 13? - How can an application verify that all legacy file paths are successfully mapped to MediaStore URIs before removing the legacy flag?