Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Getting Total Disk Space Available for Android Device
* Get the total disk space available on this Android Device
* @return total size (in bytes) that is the total disk space avaialble on the device.
public static long getTotalDiskSpace() {
StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
long totalDiskSpace = statFs.getBlockCount() * statFs.getBlockSize();
return totalDiskSpace;

This comment has been minimized.

Copy link

@m-asadullah m-asadullah commented Mar 25, 2021

As of API 18: Android 4.3 (Jelly Bean)

getBlockCount() is deprecated, so use getBlockCountLong() instead.
getBlockSize() is deprecated, so use getBlockSizeLong() instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment