Skip to content Skip to sidebar Skip to footer

How Read And Display Available Space In Android Both Sd Card And Internal Memory?

how to programmatically read and display the size of sd-card and internal memory. Internal Memory total space. used space. free space. External Memory total space. used space.

Solution 1:

Try this code:

publicstaticlongremainingLocalStorage()
{
StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
stat.restat(Environment.getDataDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getAvailableBlocks();
return bytesAvailable;
}

Solution 2:

Check this Memory Status class it has both methods to get Internal and external available storage

Solution 3:

StatFs class

you can use here, provide the path for your internal and external directory and calculate the total, free and avialable space.

StatFsmemStatus=newStatFs(Environment.getExternalStorageDirectory().getPath());

See the documentation for more details.

Post a Comment for "How Read And Display Available Space In Android Both Sd Card And Internal Memory?"