Reputation: 995
how to programmatically read and display the size of sd-card and internal memory.
any related suggestions are apreciatted
Upvotes: 2
Views: 5264
Reputation: 11359
StatFs class
you can use here, provide the path for your internal and external directory and calculate the total, free and avialable space.
StatFs memStatus = new StatFs(Environment.getExternalStorageDirectory().getPath());
See the documentation for more details.
Upvotes: 2
Reputation: 10553
Try this code:
public static long remainingLocalStorage()
{
StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
stat.restat(Environment.getDataDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getAvailableBlocks();
return bytesAvailable;
}
Upvotes: 2
Reputation: 4171
Check this Memory Status class it has both methods to get Internal and external available storage
Upvotes: 2