Code example for StatFs

Methods: getAvailableBlocks, getBlockCount, getBlockSize

0
      this.mountPoint = mountPoint;
      computeSpace(); 
    } 
 
    private void computeSpace() { 
      StatFs stat = new StatFs(mountPoint);
      long totalBytes = (long) stat.getBlockCount() *
          (long) stat.getBlockSize();
      long bytesAvailable = (long) stat.getAvailableBlocks() *
          (long) stat.getBlockSize();
      // Convert total bytes to megabytes 
      totalSpace = Math.round(totalBytes / (1024 * 1024));
      freeSpace = Math.round(bytesAvailable / (1024 * 1024));
    } 
 
    public String getLabel() {
      return label;
    } 
 
    public String getMountPoint() {
      return mountPoint;