Skip to content Skip to sidebar Skip to footer

Android How Do You Get Total Memory Ram In The Device?

I can get total available memory by: ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(

Solution 1:

Try this works for me.

publicstaticStringgetTotalRAM() {
    RandomAccessFile reader = null;
    String load = null;
    try {
        reader = newRandomAccessFile("/proc/meminfo", "r");
        load = reader.readLine();
    } catch (IOException ex) {
        ex.printStackTrace();
    } finally {
        // Streams.close(reader);
    }
    return load;
}

Solution 2:

If you don't find something else, you could bypass android and read /proc/meminfo which is what the 'free' command on a more ordinary linux distribution does

Solution 3:

MemoryInfo class has added totalMem in API 16. Please give a try.

public long totalMem Added in API level 16 The total memory accessible by the kernel. This is basically the RAM size of the device, not including below-kernel fixed allocations like DMA buffers, RAM for the baseband CPU, etc.

Post a Comment for "Android How Do You Get Total Memory Ram In The Device?"