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 {
    /**
     * @return Free size in SDcard
     */
    private static int sdFreeSize() {
        StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
        long bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
        int sdFreeMegs = (int) (bytesAvailable / (1024 * 1024));
        return sdFreeMegs;
    }
}