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"/>
The right solution will be to add android:requestLegacyExternalStorage="true"
to your AndroidManifest
file and in build.gradle
change targetSdkVersion 29
whereas keeping compileSdkVersion 30
. This should work fine.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.