Cannot create directory in android API 24 or higher devices : <p>I have developing my android app and testing it in the lowest supported SDK, which is API 18 Jellybean through an emulator (Genymotion). There is a use case where I have to download a pdf file and save it in the external storage. This works as expected in the API 18 emulator without any trouble. Then i decided to test it in my own device, which is a Huawei Honor6x with API 24, but i got a FileNotFoundException. After debugging i figured out that its not creating the directory in the external storage. To cross check if this is a problem specific to my own device, I installed 2 other emulators with API 24 (Pixel XL and Galaxy S7). I got the same error. Is there any security features blocking me from creating a folder in never versions? </p>

<p>here is my code</p>

<p>I have the following permissions</p>

<pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
&lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
</code></pre>

<p>And here is the code where i create the directory</p>

<pre><code>File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "/notespal");
    if (!directory.exists()){
        boolean created = directory.mkdirs();
    }
</code></pre>

<p>Appreciate your assistance since i have been stuck in this for few days now.  </p>
