In my flutter project, I need the device storage permission for downloading pdf. But in Android 13, in app permission settings, storage permission is not appearing.
I have used these permissions in
..android/app/src/main/AndroidManifest.xml
which is given below.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="33" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="33" />
And here is the code to take the user permission
Future<bool> requestStoragePermission(Permission permission) async {
AndroidDeviceInfo deviceInfo = await DeviceInfoPlugin().androidInfo;
if (deviceInfo.version.sdkInt >= 30) {
var status =
await Permission.manageExternalStorage.request().isGranted;
if (!status) {
await openAppSettings();
}
return status;
} else {
if (await permission.isGranted) {
return true;
} else {
var status = await permission.request();
return status.isGranted;
}
}
}
It's not working showing Permission is denied
message and debug result No permissions found in manifest for: []22
I believe when you are targeting Android 13 or above, you need to obtain access to Media Files Permission instead of READ_EXTERNAL_STORAGE
.
When you app runs in Android 13 devices, the READ_EXTERNAL_STORAGE
permission mentioned in the Android Manifest will be ignored as mentioned in this article. Instead there are three new permissions were introduced starting Android 13.
- READ_MEDIA_IMAGES
- READ_MEDIA_VIDEO
- READ_MEDIA_AUDIO.
If you were using READ_EXTERNAL_STORAGE
for accessing files, then you need to use one of these new permissions for Android 13 and above.
I would suggest you to get the more insights from the following article.
Similarly for WRITE_EXTERNAL_STORAGE
. You may check with the following article from Android which clearly explains about permission related to storage
Hope this gives you broader picture about the Android Permission Model.