get the space is left over on sdcard - Android android.os

Android examples for android.os:SD Card

Description

get the space is left over on sdcard

Demo Code

import java.io.File;

import android.os.Environment;
import android.os.StatFs;

public class Main {

  @SuppressWarnings("deprecation")
  public static long getRealSizeOnSdcard() {
    File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long availableBlocks = stat.getAvailableBlocks();
    return availableBlocks * blockSize;
  }/*from w  w  w.  j ava2  s  . c o m*/

}

Related Tutorials