Android examples for Hardware:SD Card
phone Total Capacity
//package com.java2s; import java.io.File; import java.math.BigDecimal; import android.content.Context; import android.os.Environment; import android.os.StatFs; import android.text.format.Formatter; public class Main { @SuppressWarnings("deprecation") public static final String phoneTotalCapacity(Context context) { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSizeLong(); long totalBlocks = stat.getBlockCount(); return Formatter.formatFileSize(context, blockSize * totalBlocks); }/* ww w . jav a 2s .co m*/ private static float formatFileSize(double result) { result = result / 1024; result = result / 1024; BigDecimal bBigDecimal = new BigDecimal(result); bBigDecimal = bBigDecimal.setScale(2, 4); return bBigDecimal.floatValue(); } }