Android examples for android.os:Disk
Retrieve the total size of a disk.
import android.os.StatFs; public class Main { /**//from w ww. j a va2 s .c om * Retrieve the total size of a disk. * * @param diskPath * the path of the disk. * @return the size of the disk in bytes. */ public static long getDiskTotalSize(final String diskPath) { try { final StatFs stat = new StatFs(diskPath); final long blockSize = stat.getBlockSize(); final long totalBlocks = stat.getBlockCount(); final long totalSize = blockSize * totalBlocks; return totalSize; } catch (final Throwable e) { return 0; } } }