android 手机怎么查看内存 当连接手机的时候,使用什么命令可以查到内存使用情况。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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 多点触控的问题 ? - overridePendingTransition用旋转动画 android 文件管理器中发送功能 删除listview其中一个列表项,下面的列表项向上移动的效果要怎么实现?? 请问关于类加载器的问题。关于黑马程序员的天气解析。 android下调用的webservice,一般用什么语言开发是主流? 求助:关于android atudio的avd manager FFmpeg压缩音频 Android 开发平台的搭建问题
cat /proc/cpuinfo 查看cpu
* 返回当前系统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/cpuinfo 查看cpu