Skip to content

Commit

Permalink
Merge pull request apache#556 from knight9999/(android)dev_remove_WRI…
Browse files Browse the repository at this point in the history
…TE_EXTERNAL_STORAGE

feat: remove WRITE_EXTERNAL_STORAGE permission from plugin.xml
  • Loading branch information
knight9999 authored Apr 6, 2023
2 parents b32be30 + 2eb7dc5 commit 4cd85f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ Marshmallow requires the apps to ask for permissions when reading/writing to ext
for these two directories unless external storage is not mounted. However due to a limitation, when external storage is not mounted, it would ask for
permission to write to `cordova.file.externalApplicationStorageDirectory`.

### SDK Target Less Than 29

From the official [Storage updates in Android 11](https://developer.android.com/about/versions/11/privacy/storage) documentation, the [`WRITE_EXTERNAL_STORAGE`](https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE) permission is no longer operational and does not provide access.

> If this permission is not allowlisted for an app that targets an API level before [`Build.VERSION_CODES.Q`](https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q) (SDK 29) this permission cannot be granted to apps.
If you need to add this permission, please add the following to your `config.xml`.

```xml
<config-file target="AndroidManifest.xml" parent="/*" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
</config-file>
```

## iOS Quirks

- `cordova.file.applicationStorageDirectory` is read-only; attempting to store
Expand Down
3 changes: 0 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ to config.xml in order for the application to find previously stored files.
</feature>
<allow-navigation href="cdvfile:*" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</config-file>

<source-file src="src/android/EncodingException.java" target-dir="src/org/apache/cordova/file" />
<source-file src="src/android/FileExistsException.java" target-dir="src/org/apache/cordova/file" />
Expand Down

0 comments on commit 4cd85f3

Please sign in to comment.