'Importing' a data file into a Mobile app

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: 'Importing' a data file into a Mobile app

Post by MaxV » Mon Jun 22, 2015 12:21 am

jacque wrote:Max, is your device rooted? I get nothing when querying either the files or the folders in mnt/sdcard.
No, but did you grant the permission to your app of read/write external storage?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: 'Importing' a data file into a Mobile app

Post by MaxV » Mon Jun 22, 2015 12:29 am

SparkOut wrote:Thanks Max!
Now... is it possible to tell from LC whether the user's device is set to allow/prefer external storage?
The Android approach is different. You can't know if there is a SDCARD, so you just write to /mnt/sdcard. If the phone has the sdcard inserted, you are writing in the sdcard, else in a folder.
You can just impose where to install your app using the standalone application settings.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

kurt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 21
Joined: Sat Apr 08, 2006 8:30 pm
Contact:

Re: 'Importing' a data file into a Mobile app

Post by kurt » Mon Jun 22, 2015 2:15 am

Could you use the query:

If exists [file|folder|directory]

-in this situation to establish the presence of sdcard1 (assuming sdcard0 is the internal memory).

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: 'Importing' a data file into a Mobile app

Post by MaxV » Tue Jun 23, 2015 12:35 am

kurt wrote:Could you use the query:

If exists [file|folder|directory]

-in this situation to establish the presence of sdcard1 (assuming sdcard0 is the internal memory).
It could exist /mnt/sdcard1 even without a sdcard. For example when you insert the sdcard, the sdcard is monunted in /mnt/sdcard1; but if you remove the sdcard, the director still exists.
The mounting process is a function where you substitute the content of a folder with the content of a device. Unmounting a device, you just restore the previous state.
Android OS is a mess...
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

kurt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 21
Joined: Sat Apr 08, 2006 8:30 pm
Contact:

Re: 'Importing' a data file into a Mobile app

Post by kurt » Tue Jun 23, 2015 2:46 pm

@MaxV, to be honest, I am confused a bit by the organization of the Android file system, the "emulated" shadow file system, etc. I probably should read up on it myself before I go making any further suggestions. That said....

some links:
http://android.stackexchange.com/questi ... ual-sdcard

https://source.android.com/devices/storage/index.html

The second link includes the following info:
...Starting in Android 4.4, the owner, group and modes of files on external storage devices are now synthesized based on directory structure. This enables apps to manage their package-specific directories on external storage without requiring they hold the broad WRITE_EXTERNAL_STORAGE permission. For example, the app with package name com.example.foo can now freely access Android/data/com.example.foo/ on external storage devices with no permissions....

So I would guess, assuming that you have already granted your app ext SD card access in whatever way you can in LC, and assuming you're writing for Android 4.4 and above, if you were to store your files in the precise location described above, it might work.

If you figure what works out in the context of LC, please let us know!

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: 'Importing' a data file into a Mobile app

Post by MaxV » Thu Jun 25, 2015 1:05 am

Hi kurt,
the problem is that Android is bad copy of Linux, without linux programs but tons of horrible java. Who developed Android (Google) created a real mess without indicating how to manage with external sdcard and changing linux standards. So every phone producer has is way.
At the present most of phones has one internal sdcard that is /mnt/sdcard and one external sdcard that is /mnt/sdcard2.
You can decide where store your file (which directory), your idea to test directory existence is nice, but there is no way to have the 100% of security that if you write to /mnt/sdcard2, there is an external sdcard in the phone.
For example linux has the mtab file, that it tells you of all storage device/patition mounted on the pc, but on Android it doens't exist. :cry:
However Android programmers don't care of it, if you can write, that's ok; it's the user problem to find where real are the data using other apps.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

PeterF
Posts: 1
Joined: Sat Apr 15, 2023 12:15 pm

Re: 'Importing' a data file into a Mobile app

Post by PeterF » Sat Feb 14, 2026 12:24 am

I would like to copy a txt/csv text file from external documents to documents and process it there in my application. Unfortunately that is no longer possible.

put specialfolderpath("documents") into documentspath --
put specialfolderpath("external documents") into externaldocumentspath
put "/storage/emulated/0/MyFolder/" into readableAndroidPfad -- Directory created on Android, located next to "Pictures", "Downloads".

Earlier it was possible to copy a file from external documents path into documents path.
Even copying a file from readableandroidpath into documents path worked, when textfiles are named with ".jpg".

But then I bought a new smart tablet with newer Android and nothing worked anymore. Presumably due to more restrictive read and write permissions on the part of Google/Android.
However, since other applications can still access external files without any problems today (file managers, media players, etc.), there must be a way to enable access.

Here's what I tried:
- weeks of studying the official live code documentation and the live code forums (the majority of the information there referred to outdated configurations)
- tried importing the text files from a local web server on my Android device. After all, access to HTML code still works today with accessible Internet addresses. Didn't work.
- Upgrade my Livecode license to the paid version with all necessary changes in androidversion, sdk and java version,
- Livecode set all Permissions: Sign with my key
- Ticket created with Livecode Support, receipt confirmed, no suggested solutions so far.

Android doesn't even ask for your consent to set up the rights during installation, nor does it later during the program process.

Again: I can install and enter and save data directly, but I cannot import it from outside the application via a txt/csv file.

More information: I develope in a linux system and tried Android tablets (xiaomy and Volla tablet) and Smartphones (Pixel 7 pro and Volla Phone Quintus).

Does anyone have a suggestion for a solution? For me it's about the principle and possibly incorrect settings. Thanks in advance.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7418
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: 'Importing' a data file into a Mobile app

Post by jacque » Sun Feb 15, 2026 7:51 pm

It's true Android permissions have changed. Only apps that require full file access, like file managers, can access everything without user interaction. Those apps must be specially vetted before being released in the Play Store. Other apps must put up a file dialog so that users can choose a file, essentially giving permission for access. The exception, as you noted, are URLs downloaded from the internet, particularly if they are text or html files.

There are two settings you must enable to allow internet access. One is the extension and the other is in the app settings. Make sure both are enabled. LC may automatically find the extension but may not find the app setting.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply