AppStudio QML Writing To External SD Card on Android

1779
4
01-03-2018 01:03 AM
ZdenekJankovsky
New Contributor

Hi,

I am trying to download binary files (*.geodatabase files) to Android external SD memory card.

It doesn't work:

- on Android 4.3 it downloads completely, without problem

- on Android 7.1.1 the app does NOT have write access to external memory card (checked with fileInfo isWritable function).

On 4.3. my path to folder for download is as /storage/extSdCard/DataFolder

On 7.1.1 my path to folder for a download is as /storage/870F-1E0A/DataFolder

I have checked the External Storage in my App Setting.

Why is AppStudio not able to write to external SD card on newer Android device?

Thank you.

0 Kudos
4 Replies
ZdenekJankovsky
New Contributor

It seems that, it is because of the changes in Android API from 4.4 version:

Traditional Storage  |  Android Open Source Project 

Multiple external storage devices

Starting in Android 4.4, multiple external storage devices are surfaced to developers through Context.getExternalFilesDirs(), Context.getExternalCacheDirs(), and Context.getObbDirs().

External storage devices surfaced through these APIs must be a semi-permanent part of the device (such as an SD card slot in a battery compartment). Developers expect data stored in these locations to be available over long periods of time. For this reason, transient storage devices (such as USB mass storage drives) should not be surfaced through these APIs.

The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions. Restricting writes in this way ensures the system can clean up files when applications are uninstalled.

So the question is how to get SD card storage for the app to be able to write data on it.

Thank you.

0 Kudos
nakulmanocha
Esri Regular Contributor

Hi there,

Whenever you are writing any  data in the Android internal storage or external storage like sd card. Please turn on the "External Storage" capability of the AppStudio app. This is the only requirement from AppStudio. Any path related issues are non specific to AppStudio and works the same way as other apps. If your SD card path is not working. Try using the internal storage. But please make sure you have turned on the capability as mentioned above.

Thanks,

Nakul

ZdenekJankovsky
New Contributor

Hi,

thank you for response. Yes, I have checked External Storage setting for my app and on older Android device it works as expected.

From the information I was able to gather I understand that the problem is in new permissions for Android - Qt itself had issue with it: Qt Android Bug Tracker This thread ends with the question:

Is there a plan to make this API available in QML?

Sadly without answer...

Please can somebody confirm that is able to store data on SD card for Android 7.x ?

Primary external storage works for my app, but we use quite a lot of data and older devices don't have enough space here.

0 Kudos
DustinBaumbach1
Occasional Contributor

Hi Nakul,

I have had users of my application report that they are not able to access their SD cards even though the "External Storage" selection has been turned on. Why is this happening and how can it be solved so that all android devices are able to access their SD cards? I have tried placing a few other paths in the Android Picture Chooser under the function getPaths() and will see if this helps any. The paths I have inserted are "file:///sdcard", "file:///sdcard/ext_sd", "file:///storage/extSdCard". I am going to be publishing an update tonight to see if this fixes anything. If you know of any other fixes, please respond to us here so we can implement them into our applications.

Thank you,

Dustin Baumbach

0 Kudos