本文介绍了Android的你如何在设备总内存RAM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以得到总的可用内存:
I can get total available memory by:
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
memoryInfo.availMem;
不过,你怎么弄的设备的总内存(RAM)?
However, how do you get Total memory (RAM) of the device?
我看过:http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android
它似乎并不像加pidMemoryInfo.getTotalPss()给我的总内存无论是。
It doesn't seem like adding pidMemoryInfo.getTotalPss() gives me the total memory either.
推荐答案
试试这个对我的作品。
public static String getTotalRAM() {
RandomAccessFile reader = null;
String load = null;
try {
reader = new RandomAccessFile("/proc/meminfo", "r");
load = reader.readLine();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
// Streams.close(reader);
}
return load;
}
这篇关于Android的你如何在设备总内存RAM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!