SharedPreferencesKt

Added in 1.1.0

public final class SharedPreferencesKt


Summary

Public methods

static final void
edit(
    @NonNull SharedPreferences receiver,
    boolean commit,
    @ExtensionFunctionType @NonNull Function1<@NonNull SharedPreferences.EditorUnit> action
)

Allows editing of this preference instance with a call to apply or commit to persist the changes.

Public methods

edit

public static final void edit(
    @NonNull SharedPreferences receiver,
    boolean commit,
    @ExtensionFunctionType @NonNull Function1<@NonNull SharedPreferences.EditorUnit> action
)

Allows editing of this preference instance with a call to apply or commit to persist the changes. Default behaviour is apply.

prefs.edit {
putString("key", value)
}

To commit changes:

prefs.edit(commit = true) {
putString("key", value)
}