Skip to content

Instantly share code, notes, and snippets.

@kennydude
Created December 4, 2011 12:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennydude/1430073 to your computer and use it in GitHub Desktop.
Save kennydude/1430073 to your computer and use it in GitHub Desktop.
Default Value flushable preferences in Android
import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
public class FlushCheckBoxPreference extends CheckBoxPreference implements FlushPreferences {
public FlushCheckBoxPreference(Context context, AttributeSet a) {
super(context, a);
}
public void flushDefault(Object obj) {
this.onSetInitialValue(false, (Boolean) obj);
}
}
import android.content.Context;
import android.preference.EditTextPreference;
import android.util.AttributeSet;
public class FlushEditTextPreference extends EditTextPreference implements FlushPreferences {
public FlushEditTextPreference(Context context, AttributeSet a) {
super(context, a);
}
public void flushDefault(Object obj) {
this.onSetInitialValue(false, (String) obj);
}
}
/**
*
* @author kennydude
*
*/
public interface FlushPreferences {
public void flushDefault(Object def);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment