get Real Size On Sdcard - Android Hardware

Android examples for Hardware:SD Card

Description

get Real Size On Sdcard

Demo Code


//package com.java2s;
import java.io.File;

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

public class Main {
    public static long getRealSizeOnSdcard() {
        File path = new File(Environment.getExternalStorageDirectory()
                .getAbsolutePath());// ww w  . ja va2  s .  c o m
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        return availableBlocks * blockSize;
    }
}

Related Tutorials