Share via


AbstractPreferences.GetChild(String) Method

Definition

Returns the named child if it exists, or null if it does not.

[Android.Runtime.Register("getChild", "(Ljava/lang/String;)Ljava/util/prefs/AbstractPreferences;", "GetGetChild_Ljava_lang_String_Handler")]
protected virtual Java.Util.Prefs.AbstractPreferences? GetChild (string? nodeName);
[<Android.Runtime.Register("getChild", "(Ljava/lang/String;)Ljava/util/prefs/AbstractPreferences;", "GetGetChild_Ljava_lang_String_Handler")>]
abstract member GetChild : string -> Java.Util.Prefs.AbstractPreferences
override this.GetChild : string -> Java.Util.Prefs.AbstractPreferences

Parameters

nodeName
String

name of the child to be searched for.

Returns

the named child if it exists, or null if it does not.

Attributes

Exceptions

if the backing store is unavailable or causes an operation failure.

Remarks

Returns the named child if it exists, or null if it does not. It is guaranteed that nodeName is non-null, non-empty, does not contain the slash character ('/'), and is no longer than #MAX_NAME_LENGTH characters. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for any of these things if he chooses to override this method.)

Finally, it is guaranteed that the named node has not been returned by a previous invocation of this method or #childSpi after the last time that it was removed. In other words, a cached value will always be used in preference to invoking this method. (The implementor needn't maintain his own cache of previously returned children if he chooses to override this method.)

This implementation obtains this preference node's lock, invokes #childrenNames() to get an array of the names of this node's children, and iterates over the array comparing the name of each child with the specified node name. If a child node has the correct name, the #childSpi(String) method is invoked and the resulting node is returned. If the iteration completes without finding the specified name, null is returned.

Java documentation for java.util.prefs.AbstractPreferences.getChild(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to