7

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.

  • blockSize: 4096
  • availableBlocks: 0
  • freeBlocks: 0
  • reservedBlocks: 0
  • countBlocks: 0
  • space: 0.00B / 0.00B

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

Community
  • 1
  • 1
diewland
  • 1,865
  • 5
  • 30
  • 41

1 Answers1

2

Your internal storage is not mounted in / it's in /data dir. android internal phone storage

Community
  • 1
  • 1
Mojo Risin
  • 8,136
  • 5
  • 45
  • 58
  • Thanks Risin, I think "/data" is internal space that allocated for user. But in my meaning "/" is total space in phone (OS+user). – diewland Feb 28 '11 at 02:56
  • 1
    You can try to run 'df' in android terminal - you'll se that / is not listed there. For some reason android is not providing info about /. – Mojo Risin Feb 28 '11 at 09:44