1、判断存储大小
private boolean isEnoughMem() {
File path = Environment.getDataDirectory(); // Get the path /data, this is internal storage path.
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
long memSize = availableBlocks* blockSize; // free size, unit is byte.
long mem = 1024*1024*512; /*小于512MB*/
if (memSize < mem) { //If phone available memory is less than 10M , kill activity,it will avoid force when phone low memory.
return false;
}else{
return true;
}
}