Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.ActivityManager;

import android.content.Context;

public class Main {
    /**
     * get usable memory for device
     *
     * @param context
     * @return current usable memory
     */
    public static int getDeviceUsableMemory(Context context) {
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
        activityManager.getMemoryInfo(mi);
        return (int) (mi.availMem / (1024 * 1024));
    }
}