//获得系统可用内存
private String getSystemAvaialbeMemorySize(){
ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new MemoryInfo();
mActivityManager.getMemoryInfo(memoryInfo);
long memSize = memoryInfo.availMem;
String availMemStr = Formatter.formatFileSize(CursorTest.this ,memSize);
return availMemStr;
}
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(); // free size, unit is byte.
if (memSize < 1024*1024) {//If phone available memory is less than 1M ,return
return false;
}
return true;
}