Condividi tramite


Preferences.GetBoolean(String, Boolean) Method

Definition

Returns the boolean value represented by the string associated with the specified key in this preference node.

[Android.Runtime.Register("getBoolean", "(Ljava/lang/String;Z)Z", "GetGetBoolean_Ljava_lang_String_ZHandler")]
public abstract bool GetBoolean (string? key, bool def);
[<Android.Runtime.Register("getBoolean", "(Ljava/lang/String;Z)Z", "GetGetBoolean_Ljava_lang_String_ZHandler")>]
abstract member GetBoolean : string * bool -> bool

Parameters

key
String

key whose associated value is to be returned as a boolean.

def
Boolean

the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as a boolean, or the backing store is inaccessible.

Returns

the boolean value represented by the string associated with key in this preference node, or def if the associated value does not exist or cannot be interpreted as a boolean.

Attributes

Exceptions

if this node has been removed.

if the parameter key is null.

Remarks

Returns the boolean value represented by the string associated with the specified key in this preference node. Valid strings are "true", which represents true, and "false", which represents false. Case is ignored, so, for example, "TRUE" and "False" are also valid. This method is intended for use in conjunction with #putBoolean.

Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if the associated value is something other than "true" or "false", ignoring case.

If the implementation supports stored defaults and such a default exists and is accessible, it is used in preference to the specified default, unless the stored default is something other than "true" or "false", ignoring case, in which case the specified default is used.

Java documentation for java.util.prefs.Preferences.getBoolean(java.lang.String, boolean).

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