Fail to use local files on device

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Fail to use local files on device

Post by marcopuppo » Sun Apr 23, 2017 5:53 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 ?
App deployment configuration ? My android device misconfigured ?

If I try to use the button in live code on the Mac it works with no error.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Fail to use local files on device

Post by jacque » Tue Apr 25, 2017 4:33 am

Try it this way:

Code: Select all

    on mouseUp
       put specialFolderPath("documents") & "/iphonetest.txt" into tURL
       put field "write" into URL tURL
       answer the result
    end mouseUp
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Fail to use local files on device

Post by marcopuppo » Tue Apr 25, 2017 9:29 am

Now I'm getting

invalid URL:/data/user/0/com.marcopuppo.filehandling/files/iphonetest.txt

I can't understand why I get this error with Android.

In MacOs or Windows it works fine.

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

Re: Fail to use local files on device

Post by Klaus » Tue Apr 25, 2017 10:48 am

The keyword "file:" was missing in Jaques post:

Code: Select all

on mouseUp
       put specialFolderPath("documents") & "/iphonetest.txt" into tURL
       put field "write" into URL ("file:" & tURL)
       answer the result
end mouseUp
But for whatever reason, it looks like you don't have write permission in that folder, although you definitively should!?

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

Re: Fail to use local files on device

Post by marcopuppo » Tue Apr 25, 2017 1:44 pm

Thank you

I have done the change to the instruction and the stack works once.

After that I try something on other stacks and now the stack is not working anymore. "Can't open file" again.

Maybe is something wrong in standalone settings.
Attachments
filehandling.livecode.zip
The bad stack
(2.11 KiB) Downloaded 222 times

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

Re: Fail to use local files on device

Post by Klaus » Tue Apr 25, 2017 4:51 pm

Buongiorno Marco,

settings look fine, sorry, no brilliant idea in the moment...
Someone?


Best

Klaus

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 818
Joined: Fri Feb 06, 2015 4:03 pm

Re: Fail to use local files on device

Post by LiveCode_Panos » Tue Apr 25, 2017 8:49 pm

Hi Marco,

The attached stack works as expected for me on my Android phone, tested with LiveCode 8.1.3. Clicking the "Write" button returns empty in "the result", and clicking the "Read" button returns the contents of the field that were written to "specialfolderpath("documents")/iphonetest.txt"

Which version of LiveCode are you using?

Best,
Panos
--

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

Re: Fail to use local files on device

Post by marcopuppo » Sat May 06, 2017 2:27 pm

I'm using 8.1.3 Business and 9.0.0 dp6 business.
I think is something related to the Yoga Book.

Best,

Marco

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Fail to use local files on device

Post by capellan » Wed May 10, 2017 9:18 pm

Hi Marco,

On Android this script works fine:

Code: Select all

on mouseup
       put "/mnt/sdcard/Documents/" & "phonetest.txt" into tURL
       put field "write" into URL ("file:" & tURL)
       answer the result
end mouseup
Al

Post Reply

Return to “Android Deployment”