v0.3.1: made preferences resistant to class cast exceptions, now simply return default values instead of crashing.

This commit is contained in:
Evan Debenham 2015-06-27 18:22:05 -04:00 committed by Evan Debenham
parent 7173c2cc47
commit 788937fbc1

View File

@ -52,15 +52,27 @@ enum Preferences {
}
int getInt( String key, int defValue ) {
return get().getInt( key, defValue );
try {
return get().getInt( key, defValue );
} catch (ClassCastException e) {
return defValue;
}
}
boolean getBoolean( String key, boolean defValue ) {
return get().getBoolean( key, defValue );
try {
return get().getBoolean(key, defValue);
} catch (ClassCastException e) {
return defValue;
}
}
String getString( String key, String defValue ) {
return get().getString( key, defValue );
try {
return get().getString( key, defValue );
} catch (ClassCastException e) {
return defValue;
}
}
void put( String key, int value ) {