前言
欢迎大家我分享和推荐好用的代码段~~
声明
欢迎转载,但请保留文章原始出处:
CSDN:http://www.csdn.net
雨季o莫忧离:http://blog.csdn.net/luckkof
正文
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.
if (memSize <1024*1024*10) { //If phone available memory is less than 10M , kill activity,it will avoid force when phone low memory.
return false;
}
return true;
}