get Total External Memory Size - Android Hardware

Android examples for Hardware:Memory

Description

get Total External Memory Size

Demo Code


//package com.java2s;

import android.os.Environment;

import android.os.StatFs;

import java.io.File;

public class Main {
    public static long getTotalExternalMemorySize() {
        File path = Environment.getExternalStorageDirectory();
        Environment.getExternalStorageState();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long totalBlocks = stat.getBlockCount();
        return totalBlocks * blockSize;
    }/*from   w  w w .j  av  a  2 s  .c  o m*/
}

Related Tutorials