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");
转载于:https://www.cnblogs.com/jh5240/archive/2011/10/30/2229334.html