Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.ActivityManager;

import android.content.Context;

public class Main {

    public static String getSystemMemory(Context ctx) {
        String memory = "";
        try {
            ActivityManager _ActivityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);

            ActivityManager.MemoryInfo minfo = new ActivityManager.MemoryInfo();
            _ActivityManager.getMemoryInfo(minfo);
            memory = String.valueOf(minfo.availMem / (1024 * 1024)) + "MB";
        } catch (Exception e) {
        }
        return memory;
    }
}