This is my code,
private String memSize(String path){
StatFs stat = new StatFs(path);
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
long freeBlocks = stat.getFreeBlocks();
long countBlocks = stat.getBlockCount();
String fileSize = Formatter.formatFileSize(this, availableBlocks * blockSize);
String maxSize = Formatter.formatFileSize(this, countBlocks * blockSize);
String info = path.toString()
+ "\nblockSize : " + Long.toString(blockSize)
+ "\navailableBlocks : " + Long.toString(availableBlocks)
+ "\nfreeBlocks : " + Long.toString(freeBlocks)
+ "\nreservedBlocks : " + Long.toString(freeBlocks - availableBlocks)
+ "\ncountBlocks : " + Long.toString(countBlocks)
+ "\nspace : " + fileSize + " / " + maxSize
+ "\n\n";
return info;
}
I test my function with path /data
and /sdcard
and it works
But when path is /
(I understand it is root path), this is result.
I think root path is SuperUser area. May need some permission to access.
My phone is already rooted. Could you show me what I should do next step ?
Thank you.
References
Your internal storage is not mounted in / it's in /data dir. android internal phone storage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With