I want to get full RAM size of a device. memoryInfo.getTotalPss()
returns 0. There is not function for get total RAM size in ActivityManager.MemoryInfo.
As of API level 16 you can now use the totalMem
property of the MemoryInfo
class.
Like this:
ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
actManager.getMemoryInfo(memInfo);
long totalMemory = memInfo.totalMem;
Api level 15 and lower still requires to use the unix command as shown in cweiske's answer.