get Real Size On Phone - Android Hardware

Android examples for Hardware:Storage

Description

get Real Size On Phone

Demo Code


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

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

public class Main {
    public static long getRealSizeOnPhone() {
        File path = Environment.getDataDirectory();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlocks = stat.getAvailableBlocks();
        long realSize = blockSize * availableBlocks;
        return realSize;
    }/*from   w w  w  .j a v a2  s .com*/
}

Related Tutorials