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.os.Build;
import android.os.Debug;

public class Main {
    /**Returns max memory for app
     * @return current max memory size for app
     */
    private static long calcAvailableMemory() {
        long value = Runtime.getRuntime().maxMemory();
        //String type = "";
        if (Build.VERSION.SDK_INT >= 11) {
            value = (value / 1024) - (Runtime.getRuntime().totalMemory() / 1024);
            //type = "JAVA";
        } else {
            value = (value / 1024) - (Debug.getNativeHeapAllocatedSize() / 1024);
            //type = "NATIVE";
        }

        return value;
    }
}