Best practice for writing android files? A bug in 7?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Best practice for writing android files? A bug in 7?
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.
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.
Last edited by cwkalish on Wed Jan 14, 2015 1:12 am, edited 1 time in total.
Re: Best practice for writing android files? Change w/ LC 7?
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
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?
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
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?
Hi Chuck,
in case you want to save some typing now and in the future:
Best
Klaus
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

Best
Klaus
Re: Best practice for writing android files? A bug in 7?
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.
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Best practice for writing android files? A bug in 7?
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.