Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     * **********************************************************************************************
     * 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 long TotalMemory() {
        StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
        long Total = (statFs.getBlockCountLong() * statFs.getBlockSize()) / 1048576;
        return Total;
    }
}