Android
android.content
public static interface

android.content.SharedPreferences.Editor

android.content.SharedPreferences.Editor

Interface used for modifying values in a SharedPreferences object. All changes you make in an editor are batched, and not copied back to the original SharedPreferences or persistent storage until you call commit().

Summary

Public Methods

          SharedPreferences.Editor  clear()
Mark in the editor to remove all values from the preferences.
          boolean  commit()
Commit your preferences changes back from this Editor to the SharedPreferences object it is editing.
          SharedPreferences.Editor  putBoolean(String key, boolean value)
Set a boolean value in the preferences editor, to be written back once commit() is called.
          SharedPreferences.Editor  putFloat(String key, float value)
Set a float value in the preferences editor, to be written back once commit() is called.
          SharedPreferences.Editor  putInt(String key, int value)
Set an int value in the preferences editor, to be written back once commit() is called.
          SharedPreferences.Editor  putLong(String key, long value)
Set a long value in the preferences editor, to be written back once commit() is called.
          SharedPreferences.Editor  putString(String key, String value)
Set a String value in the preferences editor, to be written back once commit() is called.
          SharedPreferences.Editor  remove(String key)
Mark in the editor that a preference value should be removed, which will be done in the actual preferences once commit() is called.

Details

Public Methods

public SharedPreferences.Editor clear()

Mark in the editor to remove all values from the preferences. Once commit is called, the only remaining preferences will be any that you have defined in this editor.

Note that when committing back to the preferences, the clear is done first, regardless of whether you called clear before or after put methods on this editor.

Returns

  • Returns a reference to the same Editor object, so you can chain put calls together.

public boolean commit()

Commit your preferences changes back from this Editor to the SharedPreferences object it is editing. This atomically performs the requested modifications, replacing whatever is currently in the SharedPreferences.

Note that when two editors are modifying preferences at the same time, the last one to call commit wins.

Returns

  • Returns true if the new values were successfully written to persistent storage.

public SharedPreferences.Editor putBoolean(String key, boolean value)

Set a boolean value in the preferences editor, to be written back once commit() is called.

Parameters

key The name of the preference to modify.
value The new value for the preference.

Returns

  • Returns a reference to the same Editor object, so you can chain put calls together.

public SharedPreferences.Editor putFloat(String key, float value)

Set a float value in the preferences editor, to be written back once commit() is called.

Parameters

key The name of the preference to modify.
value The new value for the preference.

Returns

  • Returns a reference to the same Editor object, so you can chain put calls together.

public SharedPreferences.Editor putInt(String key, int value)

Set an int value in the preferences editor, to be written back once commit() is called.

Parameters

key The name of the preference to modify.
value The new value for the preference.

Returns

  • Returns a reference to the same Editor object, so you can chain put calls together.

public SharedPreferences.Editor putLong(String key, long value)

Set a long value in the preferences editor, to be written back once commit() is called.

Parameters

key The name of the preference to modify.
value The new value for the preference.

Returns

  • Returns a reference to the same Editor object, so you can chain put calls together.

public SharedPreferences.Editor putString(String key, String value)

Set a String value in the preferences editor, to be written back once commit() is called.

Parameters

key The name of the preference to modify.
value The new value for the preference.

Returns

  • Returns a reference to the same Editor object, so you can chain put calls together.

public SharedPreferences.Editor remove(String key)

Mark in the editor that a preference value should be removed, which will be done in the actual preferences once commit() is called.

Note that when committing back to the preferences, all removals are done first, regardless of whether you called remove before or after put methods on this editor.

Parameters

key The name of the preference to remove.

Returns

  • Returns a reference to the same Editor object, so you can chain put calls together.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56