Example usage for android.preference Preference setDefaultValue

List of usage examples for android.preference Preference setDefaultValue

Introduction

In this page you can find the example usage for android.preference Preference setDefaultValue.

Prototype

public void setDefaultValue(Object defaultValue) 

Source Link

Document

Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.

Usage

From source file:be.deadba.ampd.SettingsActivity.java

private static void setupDefaultDirectoryPreference(Preference preference, PreferenceScreen ps) {
    preference.setDefaultValue(MPDConf.DEFAULT_MUSIC_DIRECTORY);
    ps.removePreference(preference);/*from   w w  w . j ava 2  s  .  c om*/
    ps.addPreference(preference);
}

From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java

private void setIncludeSubdirsSwitchPref() {
    Preference myRecCheckbox;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        myRecCheckbox = new CheckBoxPreference(this);
        ((CheckBoxPreference) myRecCheckbox).setSummaryOff(R.string.sett_recursiveSearchSummOff);
        ((CheckBoxPreference) myRecCheckbox).setSummaryOn(R.string.sett_recursiveSearchSummOn);
    } else {//w w w  .j a  v  a 2 s.c  o m
        myRecCheckbox = new MySwitchPref(this);
        ((MySwitchPref) myRecCheckbox).setSummaryOff(R.string.sett_recursiveSearchSummOff);
        ((MySwitchPref) myRecCheckbox).setSummaryOn(R.string.sett_recursiveSearchSummOn);
    }
    myRecCheckbox.setTitle(R.string.sett_recursiveSearch);
    myRecCheckbox.setSummary(R.string.sett_recursiveSearchSumm);
    myRecCheckbox.setDefaultValue(true);
    myRecCheckbox.setKey(getString(R.string.sett_key_recursiveSearch));
    if (myCat2 != null) {
        myCat2.addPreference(myRecCheckbox);
    }
}