标签:空间 剩余空间 roi false space ges pac ati log
import android.os.Environment; import android.os.StatFs; public class SdCardUtils { public static boolean hasSdcard() { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { return true; } else { return false; } } /** * 计算sdcard上的剩余空间 * * @return */ public int freeSpaceOnSd() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); // (availableBlocks * blockSize)/1024 KIB 单位 // (availableBlocks * blockSize)/1024 /1024 MIB单位 double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize()) / (1024 * 1024); return (int) sdFreeMB; } }
标签:空间 剩余空间 roi false space ges pac ati log
原文地址:http://www.cnblogs.com/loaderman/p/6435162.html