Page 1 of 1

Android Write and Read Files from stack

Posted: Sat Apr 22, 2017 6:33 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 ?

Re: Android Write and Read Files from stack

Posted: Sun Apr 23, 2017 9:30 am
by AxWald
Hi,

for debugging I'd use a slight change in code:

Code: Select all

on mouseUp
   put specialfolderpath("documents") & slash & "test.txt" into myFile
   answer "MyFile:" & CR & myFile
   put fld "write" into myData
   answer "MyData:" & CR & myData
   put myData into URL ("file:" & myFile)
   answer "file Result:"  & CR & the result
   put myData into URL ("binfile:" & myFile)
   answer "binfile Result:"  & CR & the result
end mouseUp
I don't see any obvious mistakes in your code, so checking all data carefully would be what I'd do. It should give a hint.

Have fun!