获得SD卡的剩余容量

File pathFile = Environment.getExternalStorageDirectory();
StatFs statfs = new StatFs(pathFile.getPath());
//获得可供程序使用的Block数量
long nAvailaBlock = statfs.getAvailableBlocks();
//获得SDCard上每个block的SIZE
long nBlocSize = statfs.getBlockSize();
//计算SDCard剩余大小MB
long nSDFreeSize = nAvailaBlock * nBlocSize / 1024 / 1024;
LogX.trace(TAG, "SD卡的剩余容量是:" + nSDFreeSize + "MB");

posted @ 2011-10-30 15:56  程序学习笔记  阅读(282)  评论(0编辑  收藏  举报