title: ANdroid: java.lang.IllegalArgumentException: Invalid path: /storage/extSdCard
body: <p>I am trying to get External memory size. My code is running perfectly on Lollipop and Below but give exception of invalid path  on Marshmallow and above 
  my code is here</p>
  
  <pre><code> public static String getExternalPath(){
  
      String sSDpath = null;
      File   fileCur = null;
      for( String sPathCur : Arrays.asList("MicroSD", "external_SD", "sdcard1", "ext_card", "external_sd", "ext_sd", "external", "extSdCard", "externalSdCard")) // external sdcard
      {
  
          fileCur = new File( "/mnt/", sPathCur);
          if( fileCur.isDirectory() &amp;&amp; fileCur.canWrite())
          {
              sSDpath = fileCur.getAbsolutePath();
              break;
          }
          if( sSDpath == null)  {
              fileCur = new File( "/storage/", sPathCur);
              if( fileCur.isDirectory() &amp;&amp; fileCur.canWrite())
              {
                  sSDpath = fileCur.getAbsolutePath();
                  break;
              }
          }
          if( sSDpath == null)  {
              fileCur = new File( "/storage/emulated", sPathCur);
              if( fileCur.isDirectory() &amp;&amp; fileCur.canWrite())
              {
                  sSDpath = fileCur.getAbsolutePath();
                  //Log.e("path",sSDpath);
                  break;
              }
          }
      }
      fileCur = new File( "/storage/extSdCard");
  
      return fileCur.getAbsolutePath();
  }
  </code></pre>
  
  <p>And i call this function in my Activity </p>
  
  <pre><code> public static String getExternalTotalMemory() {
      StatFs statFs2 = new StatFs(getExternalPath());
      long blockSize2 = statFs2.getBlockSize();
      final long totalSize2 = statFs2.getBlockCount() * blockSize2;;
      return  formatSize(totalSize2);
  }
  </code></pre>