Android examples for Hardware:Storage
Get free (unused) space on external storage. See Environment#getExternalStorageDirectory() .
//package com.java2s; import android.os.Environment; import android.os.StatFs; public class Main { /**//from ww w.j a v a 2 s. com * Get free (unused) space on external storage.<br> * <br> * See {@link Environment#getExternalStorageDirectory()}. * * @return free space in kilobytes */ public static int getFreeExteranlStorageSize() { StatFs stats = new StatFs(Environment.getExternalStorageDirectory() .getAbsolutePath()); int availableBlocks = stats.getAvailableBlocks(); int blockSizeInBytes = stats.getBlockSize(); return availableBlocks * (blockSizeInBytes / 1024); } }