0

I am developing an android application and I need to know how could i check if the sdcard exist or not before exporting a file to it , so that i could notify the user that the sdcard is or isn't mounted.

Andrei
  • 40,274
  • 34
  • 151
  • 206
user30102967
  • 221
  • 2
  • 12

1 Answers1

1
public boolean hasSDCard() {
    return android.os.Environment.getExternalStorageState()
              .equals(android.os.Environment.MEDIA_MOUNTED);
}
JamoBox
  • 760
  • 8
  • 22
  • 1
    Unfortunately, this is not universal, for example it returns true on my Nexus 4, which has NO SD card. See the docs for getExternalStorageState() here - http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory() – Melquiades Mar 02 '14 at 19:18