Android Write and Read Files from stack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
marcopuppo
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9
Joined: Tue Sep 07, 2010 6:49 pm

Android Write and Read Files from stack

Post by marcopuppo » Sat Apr 22, 2017 6:33 pm

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 ?

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Android Write and Read Files from stack

Post by AxWald » Sun Apr 23, 2017 9:30 am

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!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply