Flutter How to open a File in the Downloads Dir in my emulator?

458 Views Asked by At

I am using FilePicker package to open a PDF file from Downloads Dir in my emulator here is a snippet of what am doing

here iam using permission_handler package to get the permissions to access emulator files also , i ve added these lines in my AndroidManifest.xml

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

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

 if (status.isGranted) {
      // Permission is granted and files can be accessed
      result = await FilePicker.platform.pickFiles(
        type: FileType.custom,
        allowedExtensions: ['pdf'],
      );
      _document = result!.files.single.path!;
    } else {
      print("i could not access this file ");
    }

Now if i tried printing out _document it returns this /data/user/0/com.example.mindfulreaders_app/cache/file_picker/pdf-sample (4).pdf

i followed this path using "Device File Explorer tool" in Android Studio and it turned to be that the PDF file is not really in the downloads Dir of the emulator but it is saved on my laptop not the emulator

Device File Explorer SC

Now my question is why when i picked the file from Downloads Dir in my emulator the path returned is not something like this /Downloads/pdf-sample (4).pdf

0

There are 0 best solutions below