title: Unable to create directory in External Storage public directory
body: <p>I am attempting to create a directory and file so that I can store files that I have downloaded from the Internet. However, I am unable to create the directory and file in the external <em>public</em> storage. If I write to the external <em>private</em> storage (specific storage location for the app) I am perfectly able to do so.</p>
  <p>Here is the code:</p>
  <pre><code>    String storageDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath();
      System.out.println(storageDirectory);
      File mediaDir = new File(storageDirectory);
      if (!mediaDir.exists()) {
          System.out.println(mediaDir.mkdirs());
          System.out.println(mediaDir.isDirectory());
      }
      File mediaFile = new File(storageDirectory, &quot;boga.jpg&quot;);
      try {
          mediaFile.createNewFile();
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  <p>The above code results in:</p>
  <blockquote>
  <p>09-13 05:33:45.258    5867-5867/? I/System.out﹕ /storage/0CED-0F09/Pictures</p>
  </blockquote>
  <p>09-13 05:33:45.260    5867-5867/? I/System.out﹕ false</p>
  <p>09-13 05:33:45.260    5867-5867/? I/System.out﹕ false</p>
  <p>With an IOException (No such file or directory):</p>
  <blockquote>
  <p>09-13 05:33:45.260    5867-5867/? W/System.err﹕ java.io.IOException: open failed: ENOENT (No such file or directory)</p>
  <p>09-13 05:33:45.260    5867-5867/? W/System.err﹕ at java.io.File.createNewFile(File.java:939)</p>
  <p>09-13 05:33:45.260    5867-5867/? W/System.err﹕ at com.example.terabyte.tut1app.MainActivity.onCreate(MainActivity.java:78)</p>
  </blockquote>
  <p>And this is my manifest:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  </code></pre>
  <p></p>
  <pre><code>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
  &lt;application
      android:allowBackup=&quot;true&quot;
      android:icon=&quot;@mipmap/ic_launcher&quot;
      android:label=&quot;@string/app_name&quot;
      android:theme=&quot;@style/AppTheme&quot; &gt;
      &lt;activity
          android:name=&quot;.MainActivity&quot;
          android:label=&quot;@string/app_name&quot; &gt;
          &lt;intent-filter&gt;
              &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
              &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>What could be the issue?</p>