Nexus 6 Environment.getExternalStorageDirectory() cannot create directory External storage

922 Views Asked by At

I have a Nexus 6(Google Fi) I got an app that works on all other devices I tested but not on this one. Trying to create a directory or a file under this GetExternalStorageDirectory() is not working; I have tried mkdirs() as well. I cannot see the emulated/0 folder from my FileExplorer(on the phone) or from my PC(W10). And yes I do have the manifest permission for writing files. Using the following...

---Definition
public static String currentdirectory=Environment.getExternalStorageDirectory() + "/ADAK";
---Code snipplet
    sd = new File(G.currentdirectory);
    if (!sd.exists() && !sd.isDirectory()) {
        if (!sd.mkdir()) {
            G.WTL("Cannot create ADAK directory");
            G.WTS(this, "Cannot create ADAK directory");
            System.exit(0);
        }
    }
1

There are 1 best solutions below

0
On

Android 6.0 Marshmallow using API 23 have a new requirement, permissions must be requested each time the application starts. All of this is well documented by Google. http://developer.android.com/training/permissions/requesting.html