'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

Post Reply