Android Memory Get TotalMemory()

Here you can find the source of TotalMemory()

Description

* Returns size in MegaBytes.

Declaration

public static int TotalMemory() 

Method Source Code

//package com.java2s;

import android.os.Environment;
import android.os.StatFs;

public class Main {
    /**/*  w  w w  .j  a v  a 2 s  .c o  m*/
     * **********************************************************************************************
     * Returns size in MegaBytes.
     *
     * @author Dan
     * <p/>
     * If you need calculate external memory, change this: StatFs statFs
     * = new StatFs(Environment.getRootDirectory().getAbsolutePath());
     * to this: StatFs statFs = new
     * StatFs(Environment.getExternalStorageDirectory
     * ().getAbsolutePath());
     * ************************************************************************************************
     */
    public static int TotalMemory() {
        StatFs statFs = new StatFs(Environment
                .getExternalStorageDirectory().getAbsolutePath());
        int Total = (statFs.getBlockCount() * statFs.getBlockSize()) / 1048576;
        return Total;
    }
}

Related

  1. FreeMemory()