title: android - How to get Memory usage of my android device
body: <p>how you friends are doing, hope for the best.
  friends i want to how how much memory my android device does have and how much memory is used 
  active memory , inactive memory, free memory and wired memory in MB
  i have gone through <a href="https://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android">this link</a> which says about that by parsing "/system/bin/cat", "/proc/meminfo" we can get things which i mentioned above, and yes i am getting all the things but i am getting a long string where i have everything </p>
  
  <pre><code> MemTotal:         377192 kB
    MemFree:           10448 kB
    Buffers:            1368 kB``
    Cached:            74276 kB
    SwapCached:            0 kB
    Active:           143116 kB
    Inactive:         177292 kB
    Active(anon):     118388 kB
    Inactive(anon):   137664 kB
    Active(file):      24728 kB
    Inactive(file):    39628 kB
      Unevictable:       10664 kB
      Mlocked:           10372 kB
      HighTotal:        190464 kB
      HighFree:            568 kB
      LowTotal:         186728 kB
      LowFree:            9880 kB
      SwapTotal:             0 kB
      SwapFree:              0 kB
  Dirty:                 8 kB
  Writeback:             0 kB
  AnonPages:        255440 kB
  Mapped:            45816 kB
  Shmem:               624 kB
  Slab:              10952 kB
  SReclaimable:       2456 kB
  SUnreclaim:         8496 kB
  </code></pre>
  
  <p>even bigger string this i am getting from </p>
  
  <pre><code> private String ReadCPUinfo()
  {
  ProcessBuilder cmd;
  StringBuffer strMemory = new StringBuffer();
  //final ActivityManager activityManager =(ActivityManager) 
  context.getSystemService(Context.ACTIVITY_SERVICE);
  ActivityManager actvityManager = (ActivityManager) this.getSystemService(  
  ACTIVITY_SERVICE );
  ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo ();
  actvityManager.getMemoryInfo( mInfo );
  strMemory.append("Available Memory : ");
  strMemory.append(mInfo.availMem/1048576L);
  strMemory.append("\n");
  strMemory.append("\n");
  String result=strMemory.toString();
  try{
  String[] args = {"/system/bin/cat", "/proc/meminfo"};
  cmd = new ProcessBuilder(args);
  Process process = cmd.start();
  InputStream in = process.getInputStream();
  byte[] re = new byte[1024];
  while(in.read(re) != -1){
  System.out.println("itthhe   ====  ---   &gt;&gt;&gt;&gt;    "+new String(re));
  result = result + new String(re);
  }
  in.close();
  } catch(IOException ex){
  ex.printStackTrace();
  }
  return result;
  }
  </code></pre>
  
  <p>i want to whether i can break this string dynamically for diff. devices or is there any other way to find out above things</p>
  
  <p>i have also gone through <a href="https://stackoverflow.com/questions/3170691/how-to-get-current-memory-usage-in-android">this </a> but it was also not that use full .. i am easily able to get available memory info but i need all four</p>
  
  <p>any help is deeply appreciated
  thanks in adavance</p>