计算sdcard上的剩余空间代码如下:
private static int freeSpaceOnSd() {
StatFs stat = new StatFs(Environment.getExternalStorageDirectory()
.getPath());
double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat
.getBlockSize()) / MB;
return (int) sdFreeMB;
}
头文件必须引入如下:
import android.os.Environment;
import android.os.StatFs;
转自Google的文档.具体下载位置,我找不到了.