Jesus Loves You
Jesus Loves You

Reputation: 291

How to read Android 10 devices files with Flutter App

Am using this code to try to read a particular directory an android devices.. this is the code in a released application. it works fine on all devices except SamSung devices..

fetchFromOriginalDirectory() async{
    var result = await PhotoManager.requestPermission();//getting permission to check files
   if (result) {
      Directory dir = Directory('/storage/emulated/0/');


List<FileSystemEntity> _files;

_files = dir.listSync(recursive: true, followLinks: false).reversed.toList();//getting all files(stickers) in this directory
for(FileSystemEntity entity in _files) {//for each file gotten do this
  String path = entity.path;

I first thought the problem was this line "/storage/emulated/0/" but after using multiple plugins to check for the right path. i found out the paths are the same. But for some reason the app cant read the files on samsung files. even after all permissions have been granted

Upvotes: 0

Views: 1366

Answers (1)

Jesus Loves You
Jesus Loves You

Reputation: 291

Hey guys i fixed it by doing this

 <application
       
        android:requestLegacyExternalStorage="true" //adding this line
        >

In the android manifest file.

Upvotes: 3

Related Questions