public boolean isEnoughSpaceInSDcard(long fileSize) {
if (Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())) {
long avaliableSize = 0;
String storageDirectory = null;
storageDirectory = Environment.getExternalStorageDirectory()
.getAbsolutePath();
LogUtil.d("erik", "getAvailableStorage. storageDirectory : "
+ storageDirectory);
try {
StatFs stat = new StatFs(storageDirectory);
avaliableSize = ((long) stat.getAvailableBlocks() * (long) stat
.getBlockSize());
LogUtil.d("erik", "getAvailableStorage. avaliableSize : "
+ avaliableSize);
} catch (RuntimeException ex) {
return false;
}
return avaliableSize > fileSize;
} else {
return false;
}
}