Cannot access external storage - folder missing on emulator?
<p>I cannot access the external storage directory on my emulator. My app has read/write external storage permissions (emulator on Marshmallow), but making a directory fails. I looked at Device Monitor and found that the <code>sdcard</code> folder does not exist where I expect it to. Am I missing something or is my emulator corrupt?</p>

<p><a href="https://i.stack.imgur.com/ln6rA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ln6rA.png" alt="enter image description here"></a></p>

<p>Code I'm using to create the directory. <code>madeDir</code> always shows false (and the <code>mkdirs()</code> line is always run).</p>

<pre><code>//Create directory if it doesn't exist
        String path = Environment.getExternalStorageDirectory() + "/" + "MyApp/";
        // Create the parent path
        File dir = new File(path);
        boolean madeDir = false;
        if (!dir.isDirectory()) {
            madeDir = dir.mkdirs();
        }
</code></pre>

<p>Yes, I do have external storage permissions, compatible with Marshmallow. The settings on my emulator confirm that they are there. I make the following call and handle the result. </p>

<pre><code>ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, requestCode);
</code></pre>

<p><strong>Update:</strong> I'm getting this error <strong>after</strong> I have received permissions. I can try over and over and get the same error. If I restart my app, everything works fine. I am confused.</p>

<p><a href="https://i.stack.imgur.com/IqD3J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IqD3J.png" alt="enter image description here"></a></p>