0

I need to find available and used RAM space.How can I find it using android code?I have used the following code to find total RAM.

 public static String getTotalRAM() {
        RandomAccessFile reader = null;
        String load = null;
        try {
            reader = new RandomAccessFile("/proc/meminfo", "r");
            load = reader.readLine();
            Log.d("RAM ",""+load);
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            // Streams.close(reader);
        }
        return load;
    }
Monika
  • 135
  • 1
  • 12
  • 1
    possible duplicate of [How to get total RAM size of a device?](http://stackoverflow.com/questions/7374246/how-to-get-total-ram-size-of-a-device) – Alex van den Hoogen Apr 17 '14 at 12:13
  • I need to find used and available space not the total space. – Monika Apr 17 '14 at 12:31
  • Still other possible duplicate of [how to get current memory usage in android](http://stackoverflow.com/questions/3170691/how-to-get-current-memory-usage-in-android) – Alex van den Hoogen Apr 17 '14 at 12:59
  • The answers given there does not provide the correct output. – Monika Apr 17 '14 at 13:16
  • What output are you getting and what output do you expect? Which device are you testing on? – Alex van den Hoogen Apr 17 '14 at 13:33
  • I got the correct value for total RAM space using the code I have mentioned above .My output was 181 MB .When I used the code given at http://stackoverflow.com/questions/3170691/how-to-get-current-memory-usage-in-android ,I got usedMemory as 3 where as the usedRAM is 161 MB – Monika Apr 17 '14 at 13:39

0 Answers0