File path to Download folder

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

File path to Download folder

Post by KimD » Thu Feb 14, 2019 5:46 am

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: File path to Download folder

Post by jacque » Thu Feb 14, 2019 7:12 pm

Right, specialFolderPath("external documents") gives access to the public downloads folder. SpecialFolderPath(" documents") refers only to the app's sandboxed private folder. .
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: File path to Download folder

Post by SparkOut » Thu Feb 14, 2019 8:31 pm

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"

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: File path to Download folder

Post by KimD » Fri Feb 15, 2019 3:05 am

Thanks Jacque & Sparkout

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

Regards

Kim

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: File path to Download folder

Post by KimD » Wed Feb 20, 2019 3:10 am

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

Post Reply

Return to “Android Deployment”