Page 1 of 1
Fail to use local files on device
Posted: Sun Apr 23, 2017 5:53 pm
by marcopuppo
I'm trying to develop an app that runs on android and I'm testing the application on an Android Yoga Book.
I've problems to create files from the stack.
Each time I try I get in the result "can't open file".
I have downloaded the attached example from "How do I read/write to files on Mobile?" in livecode lessons.
But also with this stack I always get the same error.
the code for the button of the example is:
Code: Select all
on mouseUp
set the defaultFolder to specialFolderPath("documents")
put field "write" into URL ("file:iphonetest.txt")
answer the result
end mouseUp
I have added the "answer the result" line to check the error.
What i am doing wrong ?
App deployment configuration ? My android device misconfigured ?
If I try to use the button in live code on the Mac it works with no error.
Re: Fail to use local files on device
Posted: Tue Apr 25, 2017 4:33 am
by jacque
Try it this way:
Code: Select all
on mouseUp
put specialFolderPath("documents") & "/iphonetest.txt" into tURL
put field "write" into URL tURL
answer the result
end mouseUp
Re: Fail to use local files on device
Posted: Tue Apr 25, 2017 9:29 am
by marcopuppo
Now I'm getting
invalid URL:/data/user/0/com.marcopuppo.filehandling/files/iphonetest.txt
I can't understand why I get this error with Android.
In MacOs or Windows it works fine.
Re: Fail to use local files on device
Posted: Tue Apr 25, 2017 10:48 am
by Klaus
The keyword "file:" was missing in Jaques post:
Code: Select all
on mouseUp
put specialFolderPath("documents") & "/iphonetest.txt" into tURL
put field "write" into URL ("file:" & tURL)
answer the result
end mouseUp
But for whatever reason, it looks like you don't have write permission in that folder, although you definitively should!?
Re: Fail to use local files on device
Posted: Tue Apr 25, 2017 1:44 pm
by marcopuppo
Thank you
I have done the change to the instruction and the stack works once.
After that I try something on other stacks and now the stack is not working anymore. "Can't open file" again.
Maybe is something wrong in standalone settings.
Re: Fail to use local files on device
Posted: Tue Apr 25, 2017 4:51 pm
by Klaus
Buongiorno Marco,
settings look fine, sorry, no brilliant idea in the moment...
Someone?
Best
Klaus
Re: Fail to use local files on device
Posted: Tue Apr 25, 2017 8:49 pm
by LiveCode_Panos
Hi Marco,
The attached stack works as expected for me on my Android phone, tested with LiveCode 8.1.3. Clicking the "Write" button returns empty in "the result", and clicking the "Read" button returns the contents of the field that were written to "specialfolderpath("documents")/iphonetest.txt"
Which version of LiveCode are you using?
Best,
Panos
--
Re: Fail to use local files on device
Posted: Sat May 06, 2017 2:27 pm
by marcopuppo
I'm using 8.1.3 Business and 9.0.0 dp6 business.
I think is something related to the Yoga Book.
Best,
Marco
Re: Fail to use local files on device
Posted: Wed May 10, 2017 9:18 pm
by capellan
Hi Marco,
On Android this script works fine:
Code: Select all
on mouseup
put "/mnt/sdcard/Documents/" & "phonetest.txt" into tURL
put field "write" into URL ("file:" & tURL)
answer the result
end mouseup
Al