Is it enough to declare <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
or do I also have to declare <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
? The Javadocs omit this important information.
READ_EXTERNAL_STORAGE is necessary when you only need to read from external storage. The WRITE_EXTERNAL_STORAGE permission is necessary when your application requires the ability to write directly to external storage. It should be noted that WRITE_EXTERNAL_STORAGE implicitly includes READ_EXTERNAL_STORAGE ...
WRITE_EXTERNAL_STORAGE does not give any privileges in Android 11 (API 30), it does nothing at all, therefore in API 11 you need to set the maxSdkVersion to 29. If in Android 10 (API 29) you are also not using requestLegacyExternalStorage then set maxSdkVersion to 28 instead of 29.
To read and write data to external storage, the app required WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE system permission. These permissions are added to the AndroidManifest.
It's best to be explicit and declare both permissions, but declaring only android.permission.WRITE_EXTERNAL_STORAGE
will automatically add android.permission.READ_EXTERNAL_STORAGE
to your APK at build time.
You can use the command aapt dump badging
on an APK to see that Android considers usage of the write permission to imply that you also want read permission.
Here's some output from aapt for an APK of mine where I declared only WRITE_EXTERNAL_STORAGE
in my manifest:
uses-permission:'android.permission.WRITE_EXTERNAL_STORAGE' uses-permission:'android.permission.READ_EXTERNAL_STORAGE' uses-implied-permission:'android.permission.READ_EXTERNAL_STORAGE', 'requested WRITE_EXTERNAL_STORAGE'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With