cordova-plugin-file
cordova-plugin-file copied to clipboard
A way to NOT requre android.permission.WRITE_EXTERNAL_STORAGE?
Is there a way to NOT require android.permission.WRITE_EXTERNAL_STORAGE? Our users complain that they see that the app requires access to "Photos/Media/Files", but we don't need access to Photos and Media.
Starting in API level 19, this permission is not required to read/write files in your application-specific directories returned by Context.getExternalFilesDir(String) and Context.getExternalCacheDir().
https://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE
Internal file storage: Store app-private files on the device file system. External file storage: Store files on the shared external file system. This is usually for shared user files, such as photos.
https://developer.android.com/guide/topics/data/data-storage
Having the same problem. App does not require EXTERNAL storage, but the permission is still requested. User's are confused as to why they are being asked to grant access to Photos and Media.
In my case, downgrading to version 3.0.0 avoids the permission request.
At this time, there is no way, short of manipulating the AndroidManifest.xml before build, which you may be able to do via a hook.
I removed the support label, because I definitely see the use case here. Could be a feature request to opt in/out of adding the permission tag. The feature would have to be opt out to avoid introducing a breaking change.
a workaround I am currently using:
create a minimal cordova plugin which basically only consists of the plugin.xml where the WRITE_EXTERNAL_STORAGE permission is removed, something like
EDIT: must use
<config-file target="app/src/main/AndroidManifest.xml">instead of just<config-file target="AndroidManifest.xml">(otherwise, one of the changes might be omitted when preparing/building)
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-remove-android-write-external-storage-permission" version="0.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<name>RemoveWriteExternalStoragePermission</name>
<platform name="android">
<!-- HACK must use file="app/src/main/AndroidManifest.xml" otherwise cordova thinks this is a confict (... but with adding permissions via config-files directives ... probably a BUG in cordova-common) -->
<edit-config file="app/src/main/AndroidManifest.xml" target="/manifest" mode="merge">
<manifest xmlns:tools="http://schemas.android.com/tools" />
</edit-config>
<config-file target="app/src/main/AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />
</config-file>
</platform>
</plugin>