title: Saving to external storage
body: <p>I understand now that the "external storage" does not have to be a SDcard but is referred to another area of storage that the phone allocates to "external" as opposed to "internal". </p>
  
  <p>My problem now creating the directory for my app. When I am compiling in Android Studio using a Nexus 5 emulator, my app crashes and the error is (after creating a log) <code>Failed to create directory</code>.  </p>
  
  <p>I already added permissions and still have difficulty. I added a breakpoint to the code right before the directory is made and receive the following:</p>
  
  <p>sdcard/storage
  Pictures/Appname (I am using the pictures directory)</p>
  
  <p>After I see those strings in my logcat, it wont create the directory. Here is the code block that I am using:</p>
  
  <pre><code>File mediaStorageDir = new File(Environment.DIRECTORY_PICTURES, "AppName");
  
  if (!mediaStorageDir.exists()) {
      if (!mediaStorageDir.mkdir())
          Log.d("AppName", "failed to create directory");
      return null;
  }
  </code></pre>
  
  <p>Can anyone steer me towards me the right direction? Thank you!</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I added a check external storage :</p>
  
  <pre><code>public static boolean isExternalStorageWritable() {
      String state = Environment.getExternalStorageState();
      if (Environment.MEDIA_MOUNTED.equals(state) ||
              Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>and it returns false! I ran this before I input the code above. Any ideas?? I added the permissions (write external) and it still doesnt work.</p>