public static long getTotalSize(String device) { StatFs sf = new StatFs (device); //long totalblocks = sf.getBlockCountLong(); //long freeblocks = sf.getFreeBlocksLong();//为可用的,包含 系统保留的部分 long avablocks = sf.getAvailableBlocksLong();//可用的。不包含 系统保留的部分 long bsize = sf.getBlockSizeLong(); //long usedsize = totalblocks - freeblocks; Log.e(TAG, "totalblocks = " + totalblocks); Log.e(TAG, "totalblocksize = " + totalblocks*bsize/1024/1024); Log.e(TAG, "freeblocks = " + freeblocks); Log.e(TAG, "freeblocksize = " + freeblocks*bsize/1024/1024); Log.e(TAG, "avablocks = " + avablocks); Log.e(TAG, "avablocksize = " + avablocks*bsize/1024/1024); Log.e(TAG, "usedsize = " + usedsize*bsize/1024/1024); return 0; }
版权声明:本文博客原创文章,博客,未经同意,不得转载。