In my splash screen, I want to check if the phone has a SDCard. The Boolean statement is beneath:
Boolean isSDPresent = android.os.Environment.getExterna
This code snippet might be of use for you to detect and deal with the exception of Samsung devices:
public static String getExternalStorage() {
String str = Environment.getExternalStorageDirectory().getAbsolutePath();
if ( isSamsungDevice() ) {
if ( isSamsungExternalSDMounted() ) {
str += "/external_sd";
}
}
return str;
}
private static boolean isSamsungDevice() {
return new File( Environment.getExternalStorageDirectory().getAbsolutePath() + "/external_sd" ).exists();
}
private static boolean isSamsungExternalSDMounted() {
return exec( "mount" ).indexOf( "external_sd" ) >= 0;
}
public static String exec( String paramString ) {
try {
String str = "";
InputStream localInputStream = Runtime.getRuntime().exec( paramString ).getInputStream();
byte[] arrayOfByte = new byte[1024];
StringBuilder localStringBuilder = new StringBuilder();
while ( true ) {
int i = localInputStream.read( arrayOfByte, 0, arrayOfByte.length );
if ( i == -1 ) {
str = localStringBuilder.toString();
break;
}
localStringBuilder.append( new String( arrayOfByte, 0, i ) );
}
return str;
} catch ( IOException e ) {
e.printStackTrace();
return null;
}
}