Example usage for android.support.v4.preference PreferenceManager setDefaultValues

List of usage examples for android.support.v4.preference PreferenceManager setDefaultValues

Introduction

In this page you can find the example usage for android.support.v4.preference PreferenceManager setDefaultValues.

Prototype

public static void setDefaultValues(Context context, String sharedPreferencesName, int sharedPreferencesMode,
        int resId, boolean readAgain) 

Source Link

Document

Similar to #setDefaultValues(Context,int,boolean) but allows the client to provide the filename and mode of the shared preferences file.

Usage

From source file:com.github.preferencefragment.preference.SwitchPreference.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PreferenceManager.setDefaultValues(this, "switch", MODE_PRIVATE, R.xml.default_values, false);

    // Load the preferences from an XML resource
    getPreferenceManager().setSharedPreferencesName("switch");
    addPreferencesFromResource(R.xml.preference_switch);
}