Android How to - Check if Sd Card is available








Question

We would like to know how to check if Sd Card is available.

Answer

/*from  www  . jav a  2 s  . c  o  m*/
import android.os.Environment;

class ActivityUtils {
  public static boolean canUseSdCard() {
    try {
      return Environment.getExternalStorageState().equals(
          Environment.MEDIA_MOUNTED);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return false;
  }
}