I'm using this class to have an Encrypted EditText, it's working fine on Android < 4.2. On Android 4.2+ it's not working anymore, it's like if it's not saving the text anymore, but I'm not getting anything. Any ideas?
public class EncryptedEditTextPreference extends EditTextPreference
{
public EncryptedEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public EncryptedEditTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EncryptedEditTextPreference(Context context) {
super(context);
}
@Override
public String getText() {
String value = super.getText();
return SimpleCrypto.decrypt(value);
}
@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
super.setText(restoreValue ? getPersistedString(null) : (String) defaultValue);
}
@Override
public void setText(String text) {
try {
super.setText(SimpleCrypto.encrypt(text));
} catch (Exception e) {
Log.e(mytag, e.getMessage());
}
}
}