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
  • 42,814
  • 35
  • 154
  • 218
user30102967
  • 221
  • 2
  • 13

1 Answers1

1
public boolean hasSDCard() {
    return android.os.Environment.getExternalStorageState()
              .equals(android.os.Environment.MEDIA_MOUNTED);
}
JamoBox
  • 764
  • 9
  • 23
  • 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