public static boolean isAvaiableSpace(int sizeMb){
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
{
String sdcard = Environment.getExternalStorageDirectory().getPath();
// File file = new File(sdcard);
StatFs statFs = new StatFs(sdcard);
long blockSize = statFs.getBlockSize();
long blocks = statFs.getAvailableBlocks();
long availableSpare = (blocks*blockSize)/(1024*1024);
// int availableSpare = (int) (statFs.getBlockSize()*((long)statFs.getAvailableBlocks()-4))/(1024*1024);//以比特计算 换算成MB
System.out.println("availableSpare = " + availableSpare);
if(sizeMb>availableSpare){
return false;
}else{
return true;
}
}
return false;
}