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

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

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

Post 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.
Last edited by cwkalish on Wed Jan 14, 2015 1:12 am, edited 1 time in total.
cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

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

Post 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
cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

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

Post 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
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post 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
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

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

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

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

Post 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.
Post Reply