IT. Expert System.

Android Reference

SharedPreferences.Editor


android.content

Interface SharedPreferences.Editor

    • Method Detail

      • putString

        SharedPreferences.Editor putString(String key,
                                         String value)
        Set a String value in the preferences editor, to be written back once commit() or apply() are 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.
      • putStringSet

        SharedPreferences.Editor putStringSet(String key,
                                            Set<String> values)
        Set a set of String values in the preferences editor, to be written back once commit() is called.
        Parameters:
        key - The name of the preference to modify.
        values - The new values for the preference.
        Returns:
        Returns a reference to the same Editor object, so you can chain put calls together.
      • putInt

        SharedPreferences.Editor putInt(String key,
                                      int value)
        Set an int value in the preferences editor, to be written back once commit() or apply() are 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.
      • putLong

        SharedPreferences.Editor putLong(String key,
                                       long value)
        Set a long value in the preferences editor, to be written back once commit() or apply() are 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.
      • putFloat

        SharedPreferences.Editor putFloat(String key,
                                        float value)
        Set a float value in the preferences editor, to be written back once commit() or apply() are 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.
      • putBoolean

        SharedPreferences.Editor putBoolean(String key,
                                          boolean value)
        Set a boolean value in the preferences editor, to be written back once commit() or apply() are 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.
      • remove

        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.
      • clear

        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.
      • commit

        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.

        If you don't care about the return value and you're using this from your application's main thread, consider using apply() instead.

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

        void apply()
        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 apply wins.

        Unlike commit(), which writes its preferences out to persistent storage synchronously, apply() commits its changes to the in-memory SharedPreferences immediately but starts an asynchronous commit to disk and you won't be notified of any failures. If another editor on this SharedPreferences does a regular commit() while a apply() is still outstanding, the commit() will block until all async commits are completed as well as the commit itself.

        As SharedPreferences instances are singletons within a process, it's safe to replace any instance of commit() with apply() if you were already ignoring the return value.

        You don't need to worry about Android component lifecycles and their interaction with apply() writing to disk. The framework makes sure in-flight disk writes from apply() complete before switching states.

        The SharedPreferences.Editor interface isn't expected to be implemented directly. However, if you previously did implement it and are now getting errors about missing apply(), you can simply call commit() from apply().



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 406 / 158779042. Delta: 0.17670 с