EHS is stopping application from writing to external storage?

// Expert user has replied.
J Jon-Luke West 3 years ago
2 5 0

We have Enterprise Home Screen v2.3 installed on an Android MC40 running KK.  When we are trying to write to a file on the sdcard from within our application, no errors or exceptions are thrown in code and everything looks as if the file has been created, but it isn't.  No file is created.  I have tried this on a TC55 running KK without EHS, and it works as expected.  The file is created and written to correctly.
 
We are writing to /sdcard/ (the public external storage directory)
 
I cannot find any options in the EHS config that restrict the ability to write to external storage, but everything seems to be telling me that is exactly what is happening.  Is there an option I am not seeing in the user guide?  What is restricting me?
 
Thanks.

Please register or login to post a reply

5 Replies

A Andreas Fauerbach

Hi,

EHS does not prevent yor app from writing to external storage.
However, Android changed external storage access with KitKat:

When your app uses it's private storage folder(s), you should have no issues.

J Jon-Luke West

Thank you for your response and sharing this bit of information.

I'm a little confused about that image.  I remember seeing it and learning it while at AppForum, but I'm led to believe I can still do this according to Android Developers documentation:

I am using

File file = new File(Environment.getExternalStoragePublicDirectory(""), filename);
per Android Developer guidelines (https://developer.android.com/training/basics/data-storage/files.html#W…), and am checking for write permissions before hand with

public boolean isExternalStorageWritable() {  String state = Environment.getExternalStorageState();   if (Environment.MEDIA_MOUNTED.equals(state)) {   return true;  }   return false;}
which returns true.

and have requested appropriate permission with

This tells me that something on the MC40 is stopping my application from writing the file but not on the TC55.

To further strengthen that hypothesis; it works without any problems on the TC55 with KK.  The only 2 apparent differences between the devices, that I have identified, are the device type (MC40) and the fact that EHS is installed

Am I incorrect in this understanding?

I am going to uninstall EHS and try the operation again to satisfy my curiosity.

Thanks again.

J Jon-Luke West

After uninstalling EHS on the MC40, the application works as expected.  The file is created and written to with no errors at /storage/sdcard0 (which is what was returned by getExternalStoragePublicDirectory)

This tells me, rather conclusively, that EHS is preventing my application from writing to my files.

I am using the recommended method for writing to a file according to Android documentation:

private void submitToFile(Stringtext, String filename) {        FileOutputStream outputStream;        File file = new File(Environment.getExternalStoragePublicDirectory(""), filename);        try {            if (file.createNewFile()) {                outputStream = new FileOutputStream(file);                outputStream.write(text.getBytes());                outputStream.close();            }        } catch (Exception e) {            e.printStackTrace();        }    }

P Pietro Francesco Maggi

Hi Jon-Luke,
no errors and no exception in logcat?
that sounds very strange.

As Billie suggested, the best option is to build a small app that reproduce that issue and open a support case.

You can share the sample app even here, so we give it a try.

Ciao
~Pietro

J Jon-Luke West

Pietro,

Correct; no errors or exceptions in logcat.

I built a small app and went through the test a couple of times; after uninstalling and reinstalling EHS, everything works as expected with and without it.  I am not sure what kind of funky state the device got into.  This is very strange.

I have attached the sample app for anyone's use.

I am going to keep a close eye on this and will let everyone know if it happens again.

Thanks a bunch!

CONTACT
Can’t find what you’re looking for?