Stay organized with collections
Save and categorize content based on your preferences.
PreferenceChangeEvent
open class PreferenceChangeEvent : EventObject
An event emitted by a Preferences node to indicate that a preference has been added, removed or has had its value changed.
Note, that although PreferenceChangeEvent inherits Serializable interface from EventObject, it is not intended to be Serializable. Appropriate serialization methods are implemented to throw NotSerializableException.
Summary
Public constructors |
Constructs a new PreferenceChangeEvent instance.
|
Public methods |
open String! |
Returns the key of the preference that was changed.
|
open String! |
Returns the new value for the preference.
|
open Preferences! |
Returns the preference node that emitted the event.
|
Public constructors
PreferenceChangeEvent
PreferenceChangeEvent(
node: Preferences!,
key: String!,
newValue: String!)
Constructs a new PreferenceChangeEvent
instance.
Parameters |
node |
Preferences!: The Preferences node that emitted the event. |
key |
String!: The key of the preference that was changed. |
newValue |
String!: The new value of the preference, or null if the preference is being removed. |
Public methods
getKey
open fun getKey(): String!
Returns the key of the preference that was changed.
Return |
String! |
The key of the preference that was changed. |
getNewValue
open fun getNewValue(): String!
Returns the new value for the preference.
Return |
String! |
The new value for the preference, or null if the preference was removed. |
getNode
open fun getNode(): Preferences!
Returns the preference node that emitted the event.
Return |
Preferences! |
The preference node that emitted the event. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# PreferenceChangeEvent\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nPreferenceChangeEvent\n=====================\n\n```\nopen class PreferenceChangeEvent : EventObject\n```\n\n|---|---|--------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [java.util.EventObject](../EventObject.html#) ||\n| | ↳ | [java.util.prefs.PreferenceChangeEvent](#) |\n\nAn event emitted by a Preferences node to indicate that a preference has been added, removed or has had its value changed.\n\nNote, that although PreferenceChangeEvent inherits Serializable interface from EventObject, it is not intended to be Serializable. Appropriate serialization methods are implemented to throw NotSerializableException.\n\nSummary\n-------\n\n| Public constructors ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [PreferenceChangeEvent](#PreferenceChangeEvent(java.util.prefs.Preferences,%20kotlin.String,%20kotlin.String))`(`node:` `[Preferences](/reference/kotlin/java/util/prefs/Preferences)!`, `key:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `newValue:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Constructs a new `PreferenceChangeEvent` instance. |\n\n| Public methods ||\n|----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getKey](#getKey())`()` Returns the key of the preference that was changed. |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getNewValue](#getNewValue())`()` Returns the new value for the preference. |\n| open [Preferences](/reference/kotlin/java/util/prefs/Preferences)! | [getNode](#getNode())`()` Returns the preference node that emitted the event. |\n\n| Inherited functions ||\n|---|---|\n| From class [EventObject](../EventObject.html#) |----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------| | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | [getSource](../EventObject.html#getSource())`()` The object on which the Event initially occurred. \u003cbr /\u003e | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](../EventObject.html#toString())`()` Returns a String representation of this EventObject. \u003cbr /\u003e | ||\n\n| Inherited properties ||\n|---|---|\n| From class [EventObject](../EventObject.html#) |-----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------| | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | [source](../EventObject.html#source:kotlin.Any) The object on which the Event initially occurred. \u003cbr /\u003e | ||\n\nPublic constructors\n-------------------\n\n### PreferenceChangeEvent\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nPreferenceChangeEvent(\n node: Preferences!, \n key: String!, \n newValue: String!)\n```\n\nConstructs a new `PreferenceChangeEvent` instance.\n\n| Parameters ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `node` | [Preferences](/reference/kotlin/java/util/prefs/Preferences)!: The Preferences node that emitted the event. |\n| `key` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The key of the preference that was changed. |\n| `newValue` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The new value of the preference, or null if the preference is being removed. |\n\nPublic methods\n--------------\n\n### getKey\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getKey(): String!\n```\n\nReturns the key of the preference that was changed.\n\n| Return ||\n|-----------------------------------------------------------------------------------|---------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | The key of the preference that was changed. |\n\n### getNewValue\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getNewValue(): String!\n```\n\nReturns the new value for the preference.\n\n| Return ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | The new value for the preference, or null if the preference was removed. |\n\n### getNode\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getNode(): Preferences!\n```\n\nReturns the preference node that emitted the event.\n\n| Return ||\n|---------------------------------------------------------------|---------------------------------------------|\n| [Preferences](/reference/kotlin/java/util/prefs/Preferences)! | The preference node that emitted the event. |"]]