Get Used Memory Size : Memory « Hardware « Android






Get Used Memory Size

  
import java.text.DecimalFormat;

class Main{

    /**
     * 
     * @return
     */
    public static long getUsedMemorySize() {

        long freeSize = 0L;
        long totalSize = 0L;
        long usedSize = -1L;
        try {
            Runtime info = Runtime.getRuntime();
            freeSize = info.freeMemory();
            totalSize = info.totalMemory();
            usedSize = totalSize - freeSize;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return usedSize;

    }

}

   
    
  








Related examples in the same category

1.Get memory information
2.Get Memory Size Strings
3.Get Free Memory Size
4.Get Total Memory Size
5.Calculates the free memory of the device. This is based on an inspection of the filesystem, which in android devices is stored in RAM.
6.Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android devices is stored in RAM.
7.Get Memory Total
8.Get Memory Free
9.get MemoryInfo
10.Memory information