Just looking through the permissions for my app, and I was wondering if I need the android.permission.READ_EXTERNAL_STORAGE in my Manifest when using android:installLocation="auto".
I have had a look at the developer docs which do not mention anything about permissions, but other documentation states that I do need the permission to read from external storage:
In order to read or write files on the external storage, your app must acquire the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE system permissions.
Also, the documentation about the permission states:
Allows an application to read from external storage.
Any app that declares the WRITE_EXTERNAL_STORAGE permission is implicitly granted this permission.
This permission is enforced starting in API level 19. Before API level 19, this permission is not enforced and all apps still have access to read from external storage. You can test your app with the permission enforced by enabling Protect USB storage under Developer options in the Settings app on a device running Android 4.1 or higher.
Also starting in API level 19, this permission is not required to read/write files in your application-specific directories returned by getExternalFilesDir(String) and getExternalCacheDir().
Therefore I am not sure whether or not I do need the permission for the installLocation attribute in the Manifest file, as it means my app will read from external storage, but as I said before, the documentation specifically on App Install Location doesn't mention permissions.
Do I need the permission?
You do not need the permission.
Before Android 6.0, android:installLocation would not affect your app's internal storage (e.g., getFilesDir()). It would only affect where your APK is located. Hence, the permission does not apply.
Android 6.0 now allows users to dedicate removable storage (e.g., a micro SD card) as a place for installing apps. In this case, your internal storage happens to be on an encrypted partition put on the removable storage. However, this is still not external storage, and so the permission does not apply.
Related
Issue: Need to use Media Store API or No Access to Files
You have requested access to All Files Access permission but it appears that your app's core feature requires access to only Media Files or does not need access to any Files. In case your app needs access to Media Files, with the MediaStore API, apps can contribute and access media that's available on an external storage volume without the need for the access all files permission.
Please update your app so that the feature uses Media Store APIs and remove All Files Access (MANAGE_EXTERNAL_STORAGE) permission.
Policy: All Files Access Permission
Files and directory attributes on a user's device are regarded as personal and sensitive user data subject to the Personal and Sensitive Information policy and the following requirements:
Apps should only request access to device storage which is critical for the app to function, and may not request access to device storage on behalf of any third-party for any purpose that is unrelated to critical user-facing app functionality.
Android devices running Android "R" (Android 11) or later, will require the MANAGE_EXTERNAL_STORAGE permission in order to manage access in shared storage. All apps that target R or later and request broad access to shared storage ("All files access") must successfully pass an appropriate access review prior to publishing. Apps allowed to use this permission must clearly prompt users to enable "All files access" for their app under "Special app access" settings. For more information on the R requirements, please see this help article.
Read more about Use of All Files Access Permission
See Android storage use cases and best practices and how to access media files from shared storage
Address this issue in the Play Console.
I am working on whats-app status saver app, i don't understand how i can make it work on android 11. As storage all storage access got restricted and google rejected my update due to use of All files access (MANAGE_EXTERNAL_STORAGE) permission.
But i tested another app, which is working fine and even saving files at root directory too. This app ask for this permission Allow access to photo, media and files
and when i check permissions in app setting it says app has access to management of all files. Even app has all files permission never show me this screen to get full files access.
Just use Storage Access Framework to let the user pick the required directory.
ACTION_OPEN_DOCUMENT_TREE
I'm receiving this email in apps compiled with api 29 and api 30.
These apps does not contains requestLegacyExternalStorage flag and does not contains MANAGE_EXTERNAL_STORAGE.
I already searched in manifest merger log, and in the final merged manifest, and didn't found requestLegacyExternalStorage flag inside.
These apps only have the old and deprecated WRITE_EXTERNAL_STORAGE in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Is that old and deprecated permission which is firing that warning from google? is enough with removing that permission from my apps to get this issue solved?
Starting May 5th, you must let us know why your app requires broad
storage access
We've detected that your app contains the
requestLegacyExternalStorage flag in the manifest file of 1 or more of
your app bundles or APKs.
Developers with apps on devices running Android 11+ must use Scoped
Storage to give users better access control over their device storage.
To release your app on Android 11 or newer after May 5th, you must
either:
Update your app to use more privacy friendly best practices, such as
the Storage Access Framework or Media Store API
Update your app to declare the All files access
(MANAGE_EXTERNAL_STORAGE) permission in the manifest file, and
complete the All files access permission declaration in Play Console
from May 5th
Remove the All files access permission from your app entirely
For apps targeting Android 11, the requestLegacyExternalStorage flag
will be ignored. You must use the All files access permission to
retain broad access.
Apps requesting access to the All files access permission without a
permitted use will be removed from Google Play, and you won't be able
to publish updates.
As mentioned in the documentation, the WRITE_EXTERNAL_STORAGE permission should not be a requirement starting from API level 19. Hence, I've written this to the manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>
However, when running my app which uses Google Maps V2 and thus needs access to the external storage, I get a SecurityException:
java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
The phone I'm running the app is KitKat (4.4) which is API level 19. To my understanding, the app should be able to run fine without the permission. Why do I get the error anyway?
the WRITE_EXTERNAL_STORAGE permission should not be a requirement starting from API level 19
Only if you are using methods on Context, like getExternalFilesDir(), to get at standard locations on external storage that are specific for your app. For other locations, such as the paths reported by methods on Environment, you still need the permission.
Or, to quote the documentation that you linked to:
For example, beginning with Android 4.4 (API level 19), it's no longer necessary for your app to request the WRITE_EXTERNAL_STORAGE permission when your app wants to write to its own application-specific directories on external storage (the directories provided by getExternalFilesDir()).
Also, third-party libraries are welcome to require that you have this permission for their own reasons.
Why do I get the error anyway?
It looks like MapsV2 is validating that you have the permission as part of its setup process. That is the prerogative of MapsV2. Perhaps they are looking to work with external storage outside of the limited areas that do not require this permission. Perhaps they aren't but failed to update the permission check in their code. MapsV2, being closed source, is difficult to analyze for this sort of thing.
According to the WRITE_EXTERNAL_STORAGE documentation (emphasis mine):
Starting in API level 19, this permission is not required to
read/write files in your application-specific directories returned by
getExternalFilesDir(String) and getExternalCacheDir().
The Google Maps API is presumably using directories on the external storage that are not specific to your application, and thus you need to include the permission for all API levels.
When Android 4.1 JellyBean (API 16) was announced at Google I/O, it introduced the following permission:
READ_EXTERNAL_STORAGE
Provides protected read access to external storage. In Android 4.1 by default all applications still have read access. This will be changed in a future release to require that applications explicitly request read access using this permission. If your application already requests write access, it will automatically get read access as well. There is a new developer option to turn on read access restriction, for developers to test their applications against how Android will behave in the future.
http://developer.android.com/about/versions/android-4.1.html#Permissions
I have an application that tagets API 16 and requires the WRITE_EXTERNAL_STORAGE permission. I am preparing to deploy an update and noticed that the READ_EXTERNAL_STORAGE permission is now listed as a required permission in the developer portal. It was not listed as a required permission in Google Play for an update deployed last week. This application does not explicitly request the READ_EXTERNAL_STORAGE permission.
Will users who have already granted the WRITE_EXTERNAL_STORAGE permission for this application be prompted to grant the additional, implicit READ_EXTERNAL_STORAGE permission when they update the application?
Update:
We have since released the app and JellyBean devices are automatically updating without requesting the READ_EXTERNAL_STORAGE permission. In a future release when I explicitly declare the requirement for READ_EXTERNAL_STORAGE, will users who have already granted the WRITE_EXTERNAL_STORAGE permission be asked to grant the READ_EXTERNAL_STORAGE permission?
Since API 19 (Android 4.4) you must explicitly specify READ_EXTERNAL_STORAGE permission. Yes, if you have WRITE_EXTERNAL_STORAGE permission you will be implicitly granted READ_EXTERNAL_STORAGE but if you need a read-only access to external storage you must specify READ_EXTERNAL_STORAGE.
Prooflink: http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE
You won't have to explicitly declare READ_EXTERNAL_STORAGE so long as you have WRITE_EXTERNAL_STORAGE. Previously the OS didn't enforce readonly access to the external storage, that is changing and you must request it now. But if you have write access you implicitly get read access.
From http://developer.android.com/training/basics/data-storage/files.html
If your app needs to read the external storage (but not write to it), then you will need to declare the READ_EXTERNAL_STORAGE permission
...
However, if your app uses the WRITE_EXTERNAL_STORAGE permission, then
it implicitly has permission to read the external storage as well.