Identifier folder not visible

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
burkec
Posts: 9
Joined: Fri Jun 22, 2018 3:48 pm

Identifier folder not visible

Post by burkec » Mon Jun 25, 2018 3:24 pm

Hi folks,
I've been using LiveCode for a few years, but just recently have upgraded to LiveCode Business 9 as I'm trying to make an Android app. I have a program that I made a few years ago that runs on desktop windows/mac that I would like to deploy to mobile.
I've had some problems along the way, but form reading this forum I was able to get around them (thanks :D ).
My problem at the moment is I'm trying to write a text file to the android phone I'm testing on. I've the following code:

Code: Select all

set the defaultFolder to specialFolderPath("documents")
put gNameofFile into URL("binfile:" & specialFolderPath("documents") & slash & "data.txt") 
I can't see this file on the android. I've looked in the phone/Android/data/ and on the sdcard (mnt/sdcard/Android/data/ and can't see my identifier folder. I've changed this to com.zzzzz.zz to make is stand out, but it's not there. Any help as to why my app is not making a folder when I install it would be greatly appreciated.
Thanks,
Colin

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

Re: Identifier folder not visible

Post by SparkOut » Mon Jun 25, 2018 3:57 pm

specialFolderPath ("documents") is a sandboxed location on mobile. You would have to have your phone rooted to be able to use a file explorer to see it from anything other than your app.
You should be able to test reading the file from within your app, or check

Code: Select all

if there is a file specialFolderPath ("documents") & "/data.txt" then...
Alternatively, if you need to make the file available to other apps, you can use an alternate path, which might need a bit of testing - I think it is more consistent these days but in the past it was a bit undetermined whether it was always the same place/alias, but try "/mnt/sdcard/<folder>/<filename>" as the hard coded path without specialFolderPath - this is not the sandboxed "documents" folder.
Last edited by SparkOut on Mon Jun 25, 2018 3:59 pm, edited 1 time in total.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Identifier folder not visible

Post by Klaus » Mon Jun 25, 2018 3:59 pm

Hi burkec,

little hint:
If you provide a full path to the URL function like you do in your example,
then you do not need to set the defaultfolder first!


Best

Klaus

burkec
Posts: 9
Joined: Fri Jun 22, 2018 3:48 pm

Re: Identifier folder not visible

Post by burkec » Tue Jun 26, 2018 2:34 pm

SparkOut and Klaus, thanks for your responses!
I'm still scratching my head a bit, as I can't access the folder (my android is not rooted) nor can I write to the SD card (I've tried loads of different code). I'm deploying to my phone and running tests there. I do have it writing to a file called "testwrite" in defaultFolder("Documents") and then reading from it. I write it and read it to a label and it seems to be working well - using the following code:

Code: Select all

   put gCount & comma & gRunTime & comma & gNameOfFile into field "lblTEST"  
   set the defaultFolder to specialFolderPath("Documents")
   put field "lblTEST" into URL ("file:testwrite.txt")
and then wrtiing the contents of "testwrite" to a new label

Code: Select all

   set the defaultFolder to specialFolderPath("Documents")
   put URL ("file:testwrite.txt") into field "lblTEST2"
I do, however, want to write to a file on the SD and then allow the user to take this and look at it on their computer. This is just one of the issues I'm having.
I'm doing a series of small tests to see if the observational program I made for PC/Mac can be easily deployed for tablets (android).
1) I'm testing playing a movie clip on android - this I have done, but I cannot select a movie from the SDcard yet - I can just bundle it with the program
2) need to calculate playing times when other buttons are pressed and write this an codes to variables (easy part so far!)
3) write this file in SD card (can't do yet) - but have written to defaultFolder("Documents"), so maybe I can transfer it from there (not sure)
If I can do these 3 steps, I can recreate my program.
Thanks again for your help.
Colin

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

Re: Identifier folder not visible

Post by jacque » Tue Jun 26, 2018 5:45 pm

To read and write files outside the sandbox, select the "Write external storage" permission in Android standalone settings. Then in your scripts use specialFolderPath("external documents") to create the file paths.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

burkec
Posts: 9
Joined: Fri Jun 22, 2018 3:48 pm

Re: Identifier folder not visible

Post by burkec » Tue Jul 03, 2018 1:05 pm

Thanks Jacque for your reply. I've tried this before and for some reason it;s not working for me.
Thanks again,
COlin

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

Re: Identifier folder not visible

Post by jacque » Tue Jul 03, 2018 8:10 pm

What fails exactly?

I'm not positive, but I believe that Android apps cannot retrieve files from public storage by code. The user has to select them, which gives implicit permission. This is how iOS works, and it's reasonable since allowing any app to read and write files outside the sandbox would allow malware to do the same. Since LC does not provide a file browser for mobile apps, you'd need to write one of your own.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Android Deployment”