StatFs class
you can use here, specify the path for your internal and external directory and calculate the total, free and available space.
StatFs memStatus = new StatFs(Environment.getExternalStorageDirectory().getPath()); long bytesAvailable = (long)memStatus.getBlockSize() * (long)memStatus.getAvailableBlocks();
See the documentation for more details. bytesAvailable is in bytes, you can convert it to the format you need.
source share