Saving To A Text File - Android

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Googie85
Posts: 199
Joined: Tue Aug 05, 2014 10:07 am

Saving To A Text File - Android

Post by Googie85 » Mon Dec 07, 2015 2:38 am

I am having some issues with saving to a file on an Android device.

I have tried the following:

put "binfile:" & specialFolderPath("engine") & slash & "bell.txt" into textgoal
put "Testing 123" into URL textgoal

Also:

open file textgoal for text
write "Testing 123" to file textgoal
close file testgoal

If anyone could help with this I would be forever greatful...

Many Thanks,

Matthew.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Saving To A Text File - Android

Post by Simon » Mon Dec 07, 2015 3:13 am

Hi Matthew,
Not sure if this will solve your problem but;

Code: Select all

put "binfile:" & specialFolderPath("engine") & slash & "bell.txt" into textgoal
--should be
put ("binfile:" & specialFolderPath("engine") & slash & "bell.txt") into textgoal
and you cannot write to specialFolderPath("engine") you should use specialFolderPath("documents") if you want to record a file.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Googie85
Posts: 199
Joined: Tue Aug 05, 2014 10:07 am

Re: Saving To A Text File - Android

Post by Googie85 » Mon Dec 07, 2015 3:19 am

I'm unsure how I would save a .txt file to the documents folder instead of engine...

Many Thanks,

Matthew.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Saving To A Text File - Android

Post by Simon » Mon Dec 07, 2015 3:32 am

oops made a little mistake above;

Code: Select all

put URL("binfile:" & specialFolderPath("engine") & slash & "bell.txt") into textgoal
and to write

Code: Select all

put textgoal into URL("binfile:" & specialFolderPath("documents") & slash & "bell.txt") 
ooops ooops!
If bell.txt is really a text file then it's just URl("file:"... not URL("binfile:"...
Text is not a binary file.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Saving To A Text File - Android

Post by SparkOut » Mon Dec 07, 2015 8:33 am

Just for clarity:

specialFolderPath("documents") is a writable location, sandboxed to be accessible only to the app. Other apps will have their own sandboxed documents folder. It is not a generally accessible folder for any and all user documents. The specialFolderPath folders are automatically accessible to you app, but the names are case sensitive (ie lower case only) on mobile (mixed case is OK on desktop, and the paths have different destinations - on desktop "documents" really does mean the user documents folder).

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Saving To A Text File - Android

Post by Klaus » Mon Dec 07, 2015 2:19 pm

Hi Matt,

please spread the word: the ENGINE folder is TABOO for writing! :D
I'm unsure how I would save a .txt file to the documents folder instead of engine...
We have a specialfolderpath() for both of these, please take a look in the dictionary!


Best

Klaus

Post Reply

Return to “Android Deployment”