How to HandleExternalStorage on Android
Whether you're an Android app developer, or a user of the Android platform, you need to know how to handle external storage. The platform's default implementation of Scoped Storage is designed to protect both users and apps from malicious behavior. In addition to reducing the number of permission dialogs that users see, it also improves app performance by helping clean up duplicate files on an external drive.
Prior to Android 4.4 (KitKat) most external storage access on the device was a free-for-all where apps could read and write anywhere on an SD card. This posed a security risk to users, who often granted external storage permissions without giving the request much consideration. Malicious apps subsequently took advantage of this situation to steal data from the external storage of users, often without their knowledge.
From KitKat onward, the platform introduced a new method called getExternalFilesDir(), which allowed an app to create its own directory in external storage, and only that folder. It still needed READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions to read and write elsewhere on external storage, but this was enough of a change that users became more wary of seeing these permission requests asked for.
Since Android 11 (API level 30), the platform has further improved the handling of external storage, with additional enhancements such as raw file path access, batch edit operations for media, and an updated UI for the Storage Access Framework. The MANAGE_EXTERNAL_STORAGE access permission is retained, and apps that need it can use an intent action to allow users to enable it.