Writing to external storage on DragonBoard running Android

I’m attempting to write some text to an external file, on DragonBoard running Android. My hope would be to write the file onto the empty SD card that is mounted in the SD card slot on the DragonBoard. I’ve checked and the external storage is mounted - this method returns true:

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

But the following code always gets false from the canWrite() method:

    File fileRoot = new File(Environment.getExternalStoragePublicDirectory(DIRECTORY_DOCUMENTS), "MyAppLogs");
    if (fileRoot.canWrite()) {
        // do something here

The path returned for fileRoot is "/storage/emulated/0/Documents/MyAppLogs. If I skip the canWrite() check and execute these lines:
File LogFile = new File(fileRoot, “MyAppLog.txt”);
FileWriter LogWriter = new FileWriter(LogFile, append);
then the second of these throws a “No such file or directory” exception.

Does anyone have any insights into a) why this is failing? and b) how to get the file written onto the SD card? Thanks in advance.

I think this is likely to be a generic Android question rather than anything specific to the DB410C Android port. As such you’ll probably get more detailed advice from someplace dedicated to Android programming.

However in the mean time does your applications manifest request access to external storage? The Android security framework will prevent accesses to features if they are missing from the manifest.

Thanks for the response. The trouble with generic Android posting is that there is lots of writing out there about problems with “external storage”, and that sometimes the external storage isn’t really external at all, sometimes isn’t available, and so on. That’s why I posted here, thinking perhaps this is a Qualcomm Android issue, or perhaps Qualcomm Android users would have specific insights. But I’ll try posting elsewhere.

And yes, the manifest includes this line:
<uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” />

For sure, you absolutely welcome to post here… its more that we’ve not seen very many posts on application level questions about Android so I don’t know if there’s many folks here who have a lot more experience that you do.

Personally I’m really puzzled to see you are seeing permissions problems on /storage/emulated/0 . On a modern Android system I expected this to actually be internal storage (a whole bunch of new APIs were added for actually-external external storage in Android 5.0). However, either way, I can’t see why it would give permission errors.

One obvious thing to do would be to fire up a non-root file manager on DB410C and explore a bit. That would at least help us figure out if the question is a generic Android one or a why-is-DB410C-weird one. Basically if the file manager can access files in /storage/emulated/0 then its probably not a DB410C specific problem… and if you use an open source file manager you might even be able to see how if works!

Obviously there’s no Google Play for DB410C but I think f-droid should work OK.