Android Utililty Methods SDCard Size Get

List of utility methods to do SDCard Size Get

Description

The list of methods to do SDCard Size Get are organized into topic(s).

Method

StringgetSDPath()
get SD Path
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
    if (Environment.getExternalStorageDirectory().canWrite()) {
        return Environment.getExternalStorageDirectory().getPath();
return null;
String[]getMounts(CharSequence path)
get Mounts
BufferedReader bufferedReader = null;
try {
    bufferedReader = new BufferedReader(new FileReader(
            "/proc/mounts"), 256);
    String line;
    while ((line = bufferedReader.readLine()) != null) {
        if (line.contains(path)) {
            return line.split(" ");
...
String[]getMounts(CharSequence path)
get Mounts
BufferedReader bufferedReader = null;
try {
    bufferedReader = new BufferedReader(new FileReader(
            "/proc/mounts"), 256);
    String line;
    while ((line = bufferedReader.readLine()) != null) {
        if (line.contains(path)) {
            return line.split(" ");
...
longgetAvailableMb(String path)
get Available Mb
final long SIZE_KB = 1024L;
final long SIZE_MB = SIZE_KB * SIZE_KB;
long availableSpace = -1L;
StatFs stat = new StatFs(path);
availableSpace = (long) stat.getAvailableBlocks()
        * (long) stat.getBlockSize();
return availableSpace / SIZE_MB;
longgetUsableSpace(File path)
get Usable Space
try {
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize()
            * (long) stats.getAvailableBlocks();
} catch (Exception e) {
    e.printStackTrace();
    return -1;
longgetUsableSpace(File path)
get Usable Space
final StatFs stats = new StatFs(path.getPath());
return (long) stats.getBlockSize()
        * (long) stats.getAvailableBlocks();