[File Plugin] How to move a file (Mobile app) to the Download folder?

Hi guys,

In my mobile app (Android) I need to download a file and store it in the Download folder.

At the moment, I get to store the file using the SaveFile Action (File Plugin -Component Forge) with FilePath (input) defined as

file:///storage/emulated/0/Android/data/MY_APP_NAME.app/

But the location is not really user-friendly. So I need to move it to the main Download folder.

 When I change the input to file:///storage/emulated/0/Download(Download folder Path) the file doesn't save on the mobile device.

I appreciate any help.

Regards.


Hi Diego,


By default, files are saved into the path file:///storage/emulated/0/Android/Data/<app-id>.

When you change the path to file:///storage/emulated/0/Download, the file is still beeing saved in your device, but not into the Download folder. Probably, it is beeing saved at the default path anyways.


However this doesn't happen in every Android device. I had this exact same issue some weeks ago and I saw that in some devices the file was indeed beeing saved into the Download folder.


As I can see, this happens because different Android devices have different permissions (associated to the mobile app) to write into the Download folder. If your running your mobile app and it doesn't have permissions to write into that folder, the fill will be saved into the default path.


My suggestion is: save the file into the Documents folder.
It is clean and it is an user-friendly location as well. As far as I can tell, it is working for every Android device. You just need to define the path as Documents.


Anyways, I will leave this link for you. It is very useful to understand the File System Layouts and the physical paths on a real device (for both iOS and Android):
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/


Hope it helps,
Rui Barradas

Hi again Diego,

Did you manage to solve the problem?


Cheers,

Rui Barradas