title: Android create directory
body: <p>I'm trying to create a folder in the Downloads directory on the SDcard of an Android device. I have declared <code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;</code> in the manifest.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>String state = Environment.getExternalStorageState();
      if (!Environment.MEDIA_MOUNTED.equals(state)) {
          Log.e("file writer", "Directory not writeable");
          Toast.makeText(this, "Not writeable.",
                  Toast.LENGTH_SHORT).show();
      }
  
      File dir = new File(Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_DOWNLOADS), "myfolder");
      dir.mkdirs();
      if (!dir.mkdirs()) { Log.e("file writer", "Directory not created"); }
  </code></pre>
  
  <p>I get the "directory not created" error and there's obviously no folder where I intend there to be one.</p>