1

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

  • If you would regularly read some android tagged stackoverflow pages you would have read that this file picker makes a copy of the selected file in an apps private dir. That is the path you mentioned. It is on your device or on your emulator. Not on your laptop. Use that path. You dont need any permission i think. – blackapps May 04 '23 at 15:43
  • @blackapps i ve read much about it but i did not get across this part actually , i am glad to know it but i need to use the path that is like this /Downloads/pdf-sample (4).pdf would filepicker allow me to do this or i should go with another package as path_provider – Yusuf Abdelfattah May 04 '23 at 15:54
  • Why do you need that path? Use the one you got from filepicker. Of course filepicker cannot allow anything for other files. – blackapps May 04 '23 at 15:59
  • @blackapps i need it because after performing some modifications in that file and saving it , it simply saves that copy in that path /data/user/0/com.example.mindfulreaders_app/cache/file_picker/pdf-sample (4).pdf which i can not access it directly from the emulator device – Yusuf Abdelfattah May 04 '23 at 16:08
  • I cannot follow you. If you can edit the file on emulator you have access. – blackapps May 04 '23 at 16:09
  • no i can not , if i did some modification to the PDF it is saved in that long path that starts with /data which is only accessed by using device file explorer i needed that modified file to be saved in /Downloads so that i could open it directly from the emulator – Yusuf Abdelfattah May 04 '23 at 16:15
  • ????? Your app running on the emulator opens that file from /data/... already. So what do you need more? What do you mean with 'directly from emulator'? The emulator will not open that file but your app that runs on the emulator will. – blackapps May 04 '23 at 16:24
  • `if i did some modification to the PDF it is saved in that long path` Well not necessarily i think. You can let it save where you want. Also in the Download dir. Depending on pdf editor app. – blackapps May 04 '23 at 16:25
  • i mean that the saved file would be available in the /Downloads/ in the emulator because it is only available at /data/ and please i think i missing something about the difference between that long path of data/user... and /Downloads/... – Yusuf Abdelfattah May 04 '23 at 16:27
  • It is still pretty unclear what you want and which problems you have. Why does it take so much time to make it clear? – blackapps May 04 '23 at 16:27
  • There is no Downloads directory. There is no /Downloads/... directory. But there is a Download directory at /storage/emulated/0/Download. – blackapps May 04 '23 at 16:30
  • sorry about that and thanks for help what i mean is simply ur and my phone or phone emulator all of them have a folder Called Downloads i just want to know what is the relation between this path /data/user/0/com.example.mindfulreaders_app/cache/file_picker/pdf-sample (4).pdf and that Downloads Folder in the internal storage of the emulator Device or my real Phone – Yusuf Abdelfattah May 04 '23 at 16:32
  • yes i am taking about this /storage/emulated/0/Download actually – Yusuf Abdelfattah May 04 '23 at 16:33
  • There is no relation. It is just that your file picker makes a copy. You better could ask: "Why is my file picker making a copy instead of giving me path to picked file in Download?". – blackapps May 04 '23 at 16:34
  • yes thanks for clearing my problem now i get it that is exactly what am asking about is there is any way to prevent it from doing that copy in that path and just be sufficient with the copy of the original file in /storage/emulated/0/Download – Yusuf Abdelfattah May 04 '23 at 16:43

0 Answers0