android 手机怎么查看内存
当连接手机的时候,使用什么命令可以查到内存使用情况。 --------------------编程问答-------------------- 不需要命令。下载91手机助手就可以了。 --------------------编程问答-------------------- cat /proc/meminfo 查看内存cat /proc/cpuinfo 查看cpu --------------------编程问答-------------------- cat/proc/memoinfo 看内存好像都不详细。参数都看不懂。 --------------------编程问答-------------------- /**
* 返回当前系统RAM的大小
* @return
*/
public String getMemoryInfo() {
String value = null;
String[] cmd = { "/system/bin/cat", "/proc/meminfo" };
String workdirectory = "/system/bin/";
try {
ProcessBuilder builder = new ProcessBuilder(cmd);
InputStream in = null;
// 设置一个路径
if (workdirectory != null) {
builder.directory(new File(workdirectory));
builder.redirectErrorStream(true);
Process process = builder.start();
in = process.getInputStream();
byte[] re = new byte[1024];
while (in.read(re) != -1){
String temp = new String(re);
if(temp.startsWith("MemTotal:")){
int startIndex = temp.indexOf(":")+1;
int endIndex = temp.indexOf("\n", startIndex);
value = temp.substring(startIndex, endIndex).trim();
break ;
}
}
}
if (in != null) {
in.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return value;
}
/**
* 获得当前受的ROM大小
* @return
*/
public long[] getRomMemroy() {
long[] romInfo = new long[2];
// ROM的总大小
romInfo[0] = getTotalInternalMemorySize();
// 可用内存大小
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
romInfo[1] = blockSize * availableBlocks;
return romInfo;
}
/**
* 获得手机总内存大小
* @return
*/
public long getTotalInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return totalBlocks * blockSize;
} --------------------编程问答-------------------- cat /proc/meminfo 查看内存
cat /proc/cpuinfo 查看cpu
补充:移动开发 , Android