Issue
I'm developing a mobile app using flutter. For that I used downloads-path-provider to get the download directory of the mobile phone. The emulator returns /storage/emulated/0/Download
. Also when I save a file in this directory the file can be visible in the Download folder.
But on a real devices it also returns the same directory path. /storage/emulated/0/Download
Is this correct for the actual devices? Because on actual devices I cannot see the saved file in the Download folder.
Is there any solution to find the downloads directory on a real device?
Solution
path_provider will probably undergo some changes soon, there are some open issues:
https://github.com/flutter/flutter/issues/35783
As of right now, the best way to get the download path on an Android device is to use:
/storage/emulated/0/Download/
No (s) needed.
And to get the external dir path in Android:
/storage/emulated/0/
The "emulated" word does not mean it's the emulator path, it's just a naming convention.
Make sure you have permission to write to the file, add this to manifest.xml file, right under <manifest tag:
<manifest package="..." ... >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
and also request permission at run time.
See https://pub.dev/packages/permission_handler
Answered By - live-love
Answer Checked By - Katrina (JavaFixing Volunteer)