Android 11 Permission Issue

1,755

We need to request manage_external_storage permission via permission_handler.

Add this permission to AndroidManifest.xml

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

Request permission as shown below

await Permission.manageExternalStorage.request();

Then we can read any file and write to any location in Android 11.

Share:
1,755
Himalay
Author by

Himalay

Android Developer,Flutter Developer,Python Developer in GEC computer engineer with knowledge of high calculation in mathematics,understand issue quickly like compiler.

Updated on December 28, 2022

Comments

  • Himalay
    Himalay over 1 year

    my flutter code is

     var storageInfo = await PathProviderEx.getStorageInfo();
        var root = storageInfo[0]
            .rootDir; 
        var fm = FileManager(root: Directory(root)); 
         await fm.filesTree(
            excludedPaths: [
              '/storage/emulated/0/Android',
            ],
            extensions: ['pdf']
            );
    

    error occur

    E/flutter (16591): FileSystemException: Directory listing failed, path = '/storage/emulated/0/Android/obb' (OS Error: Permission denied, errno = 13)
    E/flutter (16591): #0      FileManager.dirsTree (package:flutter_file_manager/src/file_manager.dart:110:7)
    E/flutter (16591): #1      FileManager.filesTree (package:flutter_file_manager/src/file_manager.dart:132:34)
    

    I have one issue to get list of files from stroage in android 11 from Flutter app

    i already add both permission in AndroidManifest.xml file

     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    
    • blackapps
      blackapps about 3 years
      On an Android 11 device you have no access to the../Android/obb directory. Not even with all files access.
    • Himalay
      Himalay about 3 years
      i went to read only specific extension file from storage
    • blackapps
      blackapps about 3 years
      No you wanna list the obb directory i see.
    • Himalay
      Himalay about 3 years
      then how can i retrieve document file list from storage
    • blackapps
      blackapps about 3 years
      Please be exact. It cannot from obb directory you know now.
  • Dhaval Kansara
    Dhaval Kansara about 2 years
    we can use this but Google Play console will not allow the app with this permission to release.