public class PreferenceManagerFix
extends PreferenceManager
| Constructor and Description |
|---|
PreferenceManagerFix(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
static int |
getDefaultSharedPreferencesMode()
Returns the mode of the
SharedPreferences file that preferences will use. |
static java.lang.String |
getDefaultSharedPreferencesName(android.content.Context context)
Returns the name of the
SharedPreferences file that preferences will use. |
PreferenceScreen |
inflateFromResource(android.content.Context context,
int resId,
PreferenceScreen rootPreferences) |
static void |
setDefaultValues(android.content.Context context,
int resId,
boolean readAgain)
Sets the default values from an XML preference file by reading the values defined
by each
Preference item's android:defaultValue attribute. |
static void |
setDefaultValues(android.content.Context context,
java.lang.String sharedPreferencesName,
int sharedPreferencesMode,
int resId,
boolean readAgain)
Similar to
setDefaultValues(Context, int, boolean) but allows
the client to provide the filename and mode of the shared preferences
file. |
public PreferenceManagerFix(android.content.Context context)
public PreferenceScreen inflateFromResource(android.content.Context context,
int resId,
PreferenceScreen rootPreferences)
public static java.lang.String getDefaultSharedPreferencesName(android.content.Context context)
SharedPreferences file that preferences will use.context - the context to be usedSharedPreferences filepublic static int getDefaultSharedPreferencesMode()
SharedPreferences file that preferences will use.SharedPreferences filepublic static void setDefaultValues(android.content.Context context,
int resId,
boolean readAgain)
Preference item's android:defaultValue attribute. This should
be called by the application's main activity.
context - The context of the shared preferences.resId - The resource ID of the preference XML file.readAgain - Whether to re-read the default values.
If false, this method sets the default values only if this
method has never been called in the past (or if the
#KEY_HAS_SET_DEFAULT_VALUES in the default value shared
preferences file is false). To attempt to set the default values again
bypassing this check, set readAgain to true.
Note: this will NOT reset preferences back to their default
values. For that functionality, use
PreferenceManager#getDefaultSharedPreferences(Context)
and clear it followed by a call to this method with this
parameter set to true.
public static void setDefaultValues(android.content.Context context,
java.lang.String sharedPreferencesName,
int sharedPreferencesMode,
int resId,
boolean readAgain)
setDefaultValues(Context, int, boolean) but allows
the client to provide the filename and mode of the shared preferences
file.context - The context of the shared preferences.sharedPreferencesName - A custom name for the shared preferences file.sharedPreferencesMode - The file creation mode for the shared preferences file, such
as Context.MODE_PRIVATE or Context.MODE_PRIVATEresId - The resource ID of the preference XML file.readAgain - Whether to re-read the default values.
If false, this method will set the default values only if this
method has never been called in the past (or if the
#KEY_HAS_SET_DEFAULT_VALUES in the default value shared
preferences file is false). To attempt to set the default values again
bypassing this check, set readAgain to true.
Note: this will NOT reset preferences back to their default
values. For that functionality, use
PreferenceManager#getDefaultSharedPreferences(Context)
and clear it followed by a call to this method with this
parameter set to true.
setDefaultValues(Context, int, boolean),
#setSharedPreferencesName(String),
#setSharedPreferencesMode(int)