1String status =environment.getexternalstoragestate ();2 if(Status.equalsignorecase (environment.media_mounted)) {3Toast.maketext (Techolite. This, "SD card exists", Toast.length_long). Show ();4 //the SD is readable and writable at this time5}Else if(Status.equalsignorecase (environment.media_mounted_read_only)) {6Toast.maketext (Techolite. This, "Although SD exists, but is read-only State", Toast.length_long). Show ();7}Else if(Status.equalsignorecase (environment.media_removed)) {8Toast.maketext (Techolite. This, "SD does not exist", Toast.length_long). Show ();9}Else if(Status.equalsignorecase (environment.media_shared)) {TenToast.maketext (Techolite. This, "Although SD card exists, but it is connected with PC etc.", Toast.length_long). Show (); One}Else if(Status.equalsignorecase (environment.media_bad_removal)) { AToast.maketext (Techolite. This, "SD card is mistakenly removed in Mount State", Toast.length_long). Show (); -}Else if(Status.equalsignorecase (environment.media_checking)) { -Toast.maketext (Techolite. This, "Checking SD card", Toast.length_long). Show (); the}Else if(Status.equalsignorecase (environment.media_nofs)) { -Toast.maketext (Techolite. This, "Although the SD card exists but its file system is not supported", Toast.length_long). Show (); -}Else if(Status.equalsignorecase (environment.media_unmountable)) { -Toast.maketext (Techolite. This, "Although the SD card is present but cannot be mounted", Toast.length_long). Show (); +}Else if(Status.equalsignorecase (environment.media_unmounted)) { -Toast.maketext (Techolite. This, "Although the SD card is present but not mounted", Toast.length_long). Show (); +}Else { AToast.maketext (Techolite. This, "other reasons", Toast.length_long). Show (); at}
Determine SD card status in Android