title: android.system.ErrnoException error
body: <p>I am trying to get Internal Storage details(Storage which is used as Internal Memory) using below code.</p>
  
  <pre><code>public void getinternalstorage() {
          StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
          double bytesavalible = (double) stat.getBlockSizeLong() * (double) stat.getAvailableBlocksLong();
          final double gb = bytesavalible / (1024 * 1024 * 1024);
          double total = (double) stat.getBlockSizeLong() * stat.getBlockCountLong();
          final double totalgb = total / (1024 * 1024 * 1024);
          final double per = (100 - (gb / totalgb) * 100);
          update_inte((int) (per * 1), round(totalgb, 2), round((gb), 2));
          TextView text2written = (TextView) findViewById(R.id.inter);
          text2written.setText(String.valueOf(round((totalgb - gb), 2)) + " GB " + "/ " + String.valueOf(round(totalgb, 2)) + " GB");
      }
  </code></pre>
  
  <p><strong>I have also taken the required permissions.</strong></p>
  
  <p><strong>For Android 5.0 and below-</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><strong>For android 6.0 and above I am requesting runtime permissions.</strong></p>
  
  <p>But I have received <code>android.system.ErrnoException</code> error from around 10 users.
  Full Stack Trace</p>
  
  <pre><code>Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.package.app.Main_Screen}: java.lang.IllegalArgumentException: Invalid path: /sdcard
         at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3121)
         at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:148)
         at android.app.ActivityThread.main(ActivityThread.java:5443)
         at java.lang.reflect.Method.invoke(Method.java)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  Caused by java.lang.IllegalArgumentException: Invalid path: /sdcard
         at android.os.StatFs.doStat(StatFs.java:46)
         at android.os.StatFs.(StatFs.java)
         at com.package.app.Main_Screen.getinternalstorage(Main_Screen.java:565)
         at com.package.app.Main_Screen.on_resume(Main_Screen.java:785)
         at com.package.app.Main_Screen.checkPermission(Main_Screen.java:1070)
         at com.package.app.Main_Screen.onResume(Main_Screen.java:779)
         at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1281)
         at android.app.Activity.performResume(Activity.java:6320)
         at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3110)
         at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:148)
         at android.app.ActivityThread.main(ActivityThread.java:5443)
         at java.lang.reflect.Method.invoke(Method.java)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  Caused by android.system.ErrnoException: statvfs failed: ENOENT (No such file or directory)
         at libcore.io.Posix.statvfs(Posix.java)
         at libcore.io.BlockGuardOs.statvfs(BlockGuardOs.java:298)
         at android.system.Os.statvfs(Os.java:500)
         at android.os.StatFs.doStat(StatFs.java:44)
         at android.os.StatFs.(StatFs.java)
         at com.package.app.Main_Screen.getinternalstorage(Main_Screen.java:565)
         at com.package.app.Main_Screen.on_resume(Main_Screen.java:785)
         at com.package.app.Main_Screen.checkPermission(Main_Screen.java:1070)
         at com.package.app.Main_Screen.onResume(Main_Screen.java:779)
         at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1281)
         at android.app.Activity.performResume(Activity.java:6320)
         at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3110)
         at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:148)
         at android.app.ActivityThread.main(ActivityThread.java:5443)
         at java.lang.reflect.Method.invoke(Method.java)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  </code></pre>
  
  <p><strong>I am receiving this error from 5.0 to 7.0 Android Version</strong></p>