Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    private static final int BYTES_TO_MB = 1048576;

    /**
     * @return The total storage in MegaBytes
     */
    public static Long getTotalInternalDataSize() {
        StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
        long size = stat.getBlockCount() * stat.getBlockSize();
        return size / BYTES_TO_MB;
    }
}