Quick ExplanationString storagestate = Environment.getExternalStorageState();
--- This line gets the storage state, external means your sd-card, change it to internal then it means get the state of your phone memory.

if (!storagestate.equals(Environment.MEDIA_MOUNTED) ) { }
--- This check if the storage's state is mounted, then ! at the front would reverse the result. For more values to compare to, see Environment class