I have storage permission problem on android. storage didn’t granted permission. sdkversion is 33 and used permission_handler: ^10.2.0
. i make a permission request and check isGranted, i got false.
i’ve also put all the user-permission related to storage in AndroidManifext.xml.
Permission.storage.request();
Permission.storage.status.isGranted; # false
Purpose requiring storage permission is to create a directory and read & write a file. And one weird thing is that when you go into app info, there’s no permission for storage, there’s music and audio, photos and videos. (reference attached image) so, i touched audio, photos permission but if i create a directory, (OS Error: Permission denied, errno = 13)
apears. oh! i also touched manage storage permission but it’s not.
- i tried
flutter clean
help me…. 😥
currently my code is…
bool permissionGranted = false;
if (Platform.isAndroid) {
final androidInfo = await DeviceInfoPlugin().androidInfo;
if (androidInfo.version.sdkInt <= 32) {
Map<Permission, PermissionStatus> permissions = await [
Permission.storage,
Permission.microphone,
].request();
permissionGranted = permissions[Permission.storage]!.isGranted &&
permissions[Permission.microphone]!.isGranted;
} else {
Map<Permission, PermissionStatus> permissions = await [
Permission.photos,
Permission.microphone,
].request();
permissionGranted = permissions[Permission.photos]!.isGranted &&
permissions[Permission.microphone]!.isGranted;
}
}
Directory directory = Directory('/storage/recordings');
await directory.create(recursive: true); // this error
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.keyword_speech">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
...
android:requestLegacyExternalStorage="true">
...
2
Answers
Ridiculously, path is wrong.... I solved it using path_provider.
Try to write permissions in AndroidManifest like this –
Don’t know your exact problem but this can a solution.