Skip to content

Instantly share code, notes, and snippets.

@tushroy
Created April 22, 2014 13:55
Show Gist options
  • Save tushroy/11180204 to your computer and use it in GitHub Desktop.
Save tushroy/11180204 to your computer and use it in GitHub Desktop.
storage size android
//internal storage
StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
long blockSize = statFs.getBlockSize();
long totalSize = statFs.getBlockCount()*blockSize;
long availableSize = statFs.getAvailableBlocks()*blockSize;
long freeSize = statFs.getFreeBlocks()*blockSize;
//esternal storage
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
long blockSize = statFs.getBlockSize();
long totalSize = statFs.getBlockCount()*blockSize;
long availableSize = statFs.getAvailableBlocks()*blockSize;
long freeSize = statFs.getFreeBlocks()*blockSize;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment