How to Find The Amount of Free Storage (Disk Space) Left on Android

How to find the amount of free storage (disk space) left on Android?

Try StatFs.getAvailableBlocks. You'll need to convert the block count to KB with getBlockSize.

Correct way to check disk space available for Android app?

Well if you have the path I believe your answer can be found inside How to find the amount of free storage (disk space) left on Android?, check the code samples there.

Android get free size of internal/external memory

This is the way I did it :

StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable;
if (android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
bytesAvailable = stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
}
else {
bytesAvailable = (long)stat.getBlockSize() * (long)stat.getAvailableBlocks();
}
long megAvailable = bytesAvailable / (1024 * 1024);
Log.e("","Available MB : "+megAvailable);

Get free space on internal memory

this post might fit well to your question.

also check this thread. there is so much info here on SO.

googled a bit and here is the solution (found at android git)

File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return Formatter.formatFileSize(this, availableBlocks * blockSize);


Related Topics



Leave a reply



Submit