Java tutorial
//package com.java2s; import android.app.ActivityManager; import android.content.Context; public class Main { /** * Gets the amount of memory available to the application. * * Queries whether the largeHeap manifest flag is set. * * @param context * the application context * @return the amount of memory in bytes available to the application */ private static int getAvailableMemory(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); boolean largeHeap = (context.getApplicationInfo().flags & 1048576) != 0; int memoryClass = largeHeap ? activityManager.getLargeMemoryClass() : activityManager.getMemoryClass(); return memoryClass * 1048576; } }