get Available Memory information via MemoryInfo - Android Hardware

Android examples for Hardware:Memory

Description

get Available Memory information via MemoryInfo

Demo Code


//package com.java2s;

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;

import android.content.Context;

public class Main {

    public static long getAvailMem(Context context) {

        MemoryInfo outInfo = new ActivityManager.MemoryInfo();
        getManager(context).getMemoryInfo(outInfo);
        long availMem = outInfo.availMem;
        return availMem;
    }//from w  w  w  . j  a  va 2 s . co  m

    public static ActivityManager getManager(Context context) {
        return (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
    }
}

Related Tutorials