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 available storage in MegaBytes
     */
    public static Long getAvailableInternalDataSize() {
        StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
        long size = stat.getAvailableBlocks() * stat.getBlockSize();
        return size / BYTES_TO_MB;
    }
}