Android Java Check Whether SD Card is Available Or Not

You can check if the SD card is available by using the .getExternalStorageState and the .Environment.MEDIA_MOUNTED like this:

private Boolean isSDPresent() {
   return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
}

It returns true if the SD card is present otherwise it’s false. To use just put it into an if-statement like this:

if (isSDPresent())
{
  // SD-card is present
}
else
{
 // SD-card not present
}
Posted in Android, Tips and Tricks Tagged with: , , ,