Page 1 of 1

Best practice for writing android files? A bug in 7?

Posted: Wed Jan 07, 2015 5:47 pm
by cwkalish
What is the best way to write files that will be available outside of livecode? I'd like to have the stack write files that will be visible when the device is connected to a computer via USB, for example.

I have been using this kind of filename. But it seems that the files do not always show up.
/mnt/sdcard/music/File.txt

Thanks.

--- I believe there may be an issue with LC 7. Android apps written with 6.7 write fine but the same code does not produce a file under system 7
I think I have confirmed this by re-building a standalone from a stack written in 6.7 using 7.

Re: Best practice for writing android files? Change w/ LC 7?

Posted: Mon Jan 12, 2015 8:07 pm
by cwkalish
Does anyone have working code that reads/writes files on an android device that they could share? (especially outside of the virtual env. created for the android app)

I am completely stumped in LC 7--- I can't get any kind of directory and have no success creating files.

Thanks.
-Chuck

Re: Best practice for writing android files? Change w/ LC 7?

Posted: Wed Jan 14, 2015 1:11 am
by cwkalish
I've been able to confirm that there is a problem with LC7. Standalones build with 7 cannot write files, while those built with 6.7 can. Here's the code that works w/ 6.7 but not 7. I'll submit this as a bug report (but maybe someone else wants to try...)

Chuck

on mouseUp
put "/mnt/sdcard/music/" into fname
put fname&"TestSys"&random(100)&".txt" into fname
open file fname
write fld "tfld" to file fname
close file fname
end mouseUp

Re: Best practice for writing android files? A bug in 7?

Posted: Wed Jan 14, 2015 3:49 pm
by Klaus
Hi Chuck,

in case you want to save some typing now and in the future:

Code: Select all

on mouseUp
   put fld "tfld" into url("file:/mnt/sdcard/music/TestSys" & random(100) & ".txt")
end mouseUp
:D


Best

Klaus

Re: Best practice for writing android files? A bug in 7?

Posted: Wed Jan 14, 2015 6:57 pm
by jacque
Double-check your standalone settings and make sure that "Write external storage" permissions are enabled.

If that doesn't work, you may be hitting the sandbox rules which disallow apps from writing outside their designated app locations. Did your previous app also write to the Music folder? See if you can write to specialFolderPath("documents"). If that works, then the sandbox is likely the problem.

Re: Best practice for writing android files? A bug in 7?

Posted: Fri Jan 16, 2015 2:20 pm
by cwkalish
I was able to test that the same code compiled with LC 6.7.1 does write the file. I submitted a bug report and got a message back that it was confirmed.