Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.StatFs;

import android.util.Log;

import java.io.File;

public class Main {
    public static long getAvailableSpace(File dir) {
        try {
            final StatFs stats = new StatFs(dir.getPath());
            return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
        } catch (Throwable e) {
            Log.e("getAvailableSpace", e.getMessage(), e);
            return -1;
        }
    }
}