Page 1 of 1

File path to Download folder

Posted: Thu Feb 14, 2019 5:46 am
by KimD
Hi

The scenario that I'm trying to address is, on Android:
1) User A emails a data file to user B
2) Within their email programme, User B selects the option to "download" the data file
The data file is now sitting in a "Download" folder of user B's Android device.

I know that, in general, Android ring-fences the data specific to each app, but it seems to me that the Download folder must be an exception to this because lots of apps seem to be able to write to / read from the same Download folder.

I know that there can be more than one download folder (e.g. one on internal storage, one on external storage).

If I have a file XYZ in the download folder of an Android devices internal storage, what file path do I use to access it?

"file:" & specialFolderPath("Download") & slash & "XYZ" - would be nice, but specialFolderPath("Download") seems to only exist on my wish-list

Is the answer something to do with specialFolderPath("External Documents")?

Thanks in advance

Kim

Re: File path to Download folder

Posted: Thu Feb 14, 2019 7:12 pm
by jacque
Right, specialFolderPath("external documents") gives access to the public downloads folder. SpecialFolderPath(" documents") refers only to the app's sandboxed private folder. .

Re: File path to Download folder

Posted: Thu Feb 14, 2019 8:31 pm
by SparkOut
Also a point of note, on Android (and IOS too, I believe) the filesystem is case sensitive, and specialFolderPath ("documents") has a lower case "d"

Re: File path to Download folder

Posted: Fri Feb 15, 2019 3:05 am
by KimD
Thanks Jacque & Sparkout

I've ended up having to debug another problem today, but I'll try your suggestions on Monday.

Regards

Kim

Re: File path to Download folder

Posted: Wed Feb 20, 2019 3:10 am
by KimD
Hi

FYI

With a sample size of one (Android 5.01) test device:
- I couldn't get specialFolderPath("external documents") to work. This evaluated to "/storage/emulated/0/android/data/myappname/files", which wasn't the Download folder; but
- after a fair bit of experimentation I got "/mnt/sdcard/Download" to work. This evaluated to "/storage/emulated/legacy/Download"

I did also find a bunch of posts on stackOverflow implying that Environment.getExternalStorageState() or Environment.getDataDirectory() would give me a robust generic answer to "What's the file path to the Download folder", but I didn't know how to run an Android operating system (or is it Java) command from LC, so for the moment at least I'm going to have to run with "/mnt/sdcard/Download". Now to see if it works on a sample of later versions of Android.

Thanks for your posts

Kim