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 MB = 1024 * 1024;
    private static int MIN_SIZE_MB = 10;

    public static boolean isAvaiableSpace() {
        int size = (int) getFreeSpaceOnSd() / MB;
        return size > MIN_SIZE_MB;
    }

    public static long getFreeSpaceOnSd() {
        StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
        //double sdFreeMB = ((double)stat.getAvailableBlocks() * (double) stat.getBlockSize()) / MB;
        return stat.getAvailableBlocks() * stat.getBlockSize();
    }
}