title: How to create folder in external storage?
body: <p>This is what I tried.</p>
  
  <pre><code> private void createFolderInExternalStorage() {
      String storagePath = System.getenv("SECONDARY_STORAGE");
      Log.e("storagePath-&gt;",storagePath);
      String path = "not available";
      if (storagePath != null) {
          Log.e("Path-&gt;", "" + storagePath);
          File file = new File(storagePath.toString());
          Log.e("readable-&gt;", "" + file.canRead());
          Log.e("writable-&gt;", "" + file.canWrite());
          Log.e("executable-&gt;", "" + file.canExecute());
          dir = new File(storagePath + File.separator+etFolder.getText().toString());
          if (!dir.exists()) {
              dir.mkdirs();
              Toast.makeText(this,"Folder "+etFolder.getText().toString()+" created",Toast.LENGTH_SHORT).show();
          }else{
              Toast.makeText(this,"Folder "+etFolder.getText().toString()+" already exists",Toast.LENGTH_SHORT).show();
          }
          path = dir.getPath();
      } else {
          Toast.makeText(this,"External Storage not available",Toast.LENGTH_SHORT).show();
      }
      tv.setText("External SDCARD path-&gt;" + path);
  }
  </code></pre>
  
  <blockquote>
    <p>if Secondary storage is present then System.getenv("SECONDARY_STORAGE") return  /storage/sdcard1 in my case but getting following:</p>
    
    <p>03-21 12:02:26.827 14155-14155/com.think.teststorage E/readable->: false</p>
    
    <p>03-21 12:02:26.827 14155-14155/com.think.teststorage E/writable->: false</p>
    
    <p>03-21 12:02:26.828 14155-14155/com.think.teststorage E/executable->: false</p>
    
    <p><strong><em>Even in some devices getting the above status as true but folder creation fails.</em></strong></p>
  </blockquote>
  
  <p><strong>I have added the permission:</strong></p>
  
  <pre><code>    &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  </code></pre>
  
  <p>Suggestions are welcome.</p>