/**
* 判断是否有足够的空间供下载
*
* @param downloadSize
* @return
*/
public boolean isEnoughForDownload(long downloadSize)
{
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory()
.getAbsolutePath());
//sd卡分区数
int blockCounts = statFs.getBlockCount();
Log.e("ray", "blockCounts" + blockCounts);
//sd卡可用分区数
int avCounts = statFs.getAvailableBlocks();
Log.e("ray", "avCounts" + avCounts);
//一个分区数的大小
long blockSize = statFs.getBlockSize();
Log.e("ray", "blockSize" + blockSize);
//sd卡可用空间
long spaceLeft = avCounts * blockSize;
Log.e("ray", "spaceLeft" + spaceLeft);
Log.e("ray", "downloadSize" + downloadSize);
if (spaceLeft < downloadSize)
{
return false;
}
return true;
}