How to save XML file to SD Card

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

How to save XML file to SD Card

Post by Texter » Sat Aug 25, 2018 5:49 pm

Hello

I found many informations on the internet about this problem but nothing works.
Maybe someone can help me.

My app is creating a XML file and I can save it on my Android Tablet to the internal storage with this code.

put textencode(tXMLFinal,"UTF8") into URL ("file:/mnt/sdcard/documents/Test.xml")

I am confused about this, because I use sdcard and the file is not on the sd card. It is on the internal storage.
I tryed different code with sdcard2, external and so on, but nothing!

How can I solve this problem.

The app is on Android 4.1, the Tablet is Android 7
But I think this should not be the problem.

Thanks Texter

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

Re: How to save XML file to SD Card

Post by Klaus » Sat Aug 25, 2018 6:13 pm

Hi texter,

try -> specialfolderpath("external documents")

Code: Select all

put textencode(tXMLFinal,"UTF8") into URL ("file:" & specialfolderpath("external documents") & "/test.xml")
From the dicitonary about specialfolderpaths on ANDROID:
...
"external documents": The folder on the primary shared/external storage device where application-specific data can be placed
...
Note: If using any external folderIdentifier values, ensure you have the 'Write External Storage' permission checked in the application standalone settings
...

Hope that helps.


Best

Klaus

Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

Re: How to save XML file to SD Card

Post by Texter » Sat Aug 25, 2018 6:55 pm

Thank you Klaus

I will try it tomorrow

Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

Re: How to save XML file to SD Card

Post by Texter » Sun Aug 26, 2018 7:35 am

Hi Klaus

I tried the code with external documents but the file was saved in

/storage/emulated/0/Android/data/com.yourcompany.yourapp/files

in the internal storage of the Tablet

Dont know whats the problem

Texter

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

Re: How to save XML file to SD Card

Post by Klaus » Sun Aug 26, 2018 6:15 pm

Hi texter,

I do not own any mobile device (no cellphone, yep, that's me :-)), so I can only be of theoretical help.
Did you check "Write external storage" in the standalone builder settings for Android?


Best

Klaus

Texter
Posts: 19
Joined: Mon Jun 18, 2018 5:17 pm

Re: How to save XML file to SD Card

Post by Texter » Sun Aug 26, 2018 6:39 pm

hello Klaus

Setting for write external storage is checked.

But until now I could only save to internal storage.

I have no idea how to change this.

Thanks Klaus

Texter

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

Re: How to save XML file to SD Card

Post by jacque » Sun Aug 26, 2018 10:25 pm

Try setting the Install Location to "Prefer external storage". If that doesn't work you'll need to figure out the path to the SD card. Unfortunately that will vary depending on the device or the manufacturer.

External SDCard file path for Android:
https://www.google.com/url?sa=t&rct=j&q ... 6axni_r5Ki
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Android Deployment”