Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MANAGE_EXTERNAL_STORAGE vs WRITE_EXTERNAL_STORAGE

I had to implement a functionality to save a local file on the download folder recently. This challenge came with some questions that I don't have found the answers yet.

What is the difference between MANAGE_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE with READ_EXTERNAL_STORAGE ?

Here is the description of google for MANAGE_EXTERNAL_STORAGE

Google Play restricts the use of high risk or sensitive permissions, including a special app access called All files access. This is only applicable to apps that target Android 11 (API level 30) and declare the MANAGE_EXTERNAL_STORAGE permission...

And the definition of WRITE_EXTERNAL_STORAGE

Allows an application to write to external storage. Starting in API level 19, this permission is not required to read/write files in your application-specific directories...

So, what's the difference? When should I use each one? Why Google need 3 permissions to handle external storage? What should I ask to save a file on Downloads folder?

like image 729
Firus Avatar asked Dec 06 '25 17:12

Firus


1 Answers

MANAGE_EXTERNAL_STORAGE:

  • Is for Android 11 and higher
  • Allows for nearly complete read/write access to what the SDK refers to as external storage
  • Will cause your app to be banned from distribution on the Play Store (and perhaps elsewhere), unless you can justify to Google that the permission is necessary, and that is very difficult

WRITE_EXTERNAL_STORAGE:

  • Is for all current versions of Android
  • On Android 9 and lower (and Android 10 with android:requestLegacyExternalStorage="true"), allows for write access to all of what the SDK refers to as external storage
  • On Android 11+, allows for write access to a handful of public locations
  • Does not require Google's permission to use for apps on the Play Store

Why Google need 3 permissions to handle external storage?

Because things have changed over time. Approaches that were deemed appropriate for Android 2.x (WRITE_EXTERNAL_STORAGE having complete write access to external storage) have had problems.

What should I ask to save a file on Downloads folder?

Most likely, the answer is "do not write to Downloads/". Bear in mind that you do not have read access to Downloads/ on Android 11+ to files that your app did not create. This means that if you try to write a file there, and there is already a file by that name created by something else, you fail with an error — you do not have the ability to overwrite files created by other apps.

Generally, the better answer is to use ACTION_CREATE_DOCUMENT / ActivityResultContracts.CreateDocument and allow the user to tell you where on the user's local or cloud storage where the user would like you to put this content.

However, if you insist on using Downloads/, WRITE_EXTERNAL_STORAGE should be sufficient.

like image 146
CommonsWare Avatar answered Dec 08 '25 07:12

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!