Share via


AbstractPreferences.GetBoolean(String, Boolean) Method

Definition

Implements the getBoolean method as per the specification in Preferences#getBoolean(String,boolean).

[Android.Runtime.Register("getBoolean", "(Ljava/lang/String;Z)Z", "GetGetBoolean_Ljava_lang_String_ZHandler")]
public override bool GetBoolean (string? key, bool def);
[<Android.Runtime.Register("getBoolean", "(Ljava/lang/String;Z)Z", "GetGetBoolean_Ljava_lang_String_ZHandler")>]
override this.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.

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

Remarks

Implements the getBoolean method as per the specification in Preferences#getBoolean(String,boolean).

This implementation invokes #get(String,String) <tt>get(key, null)</tt>. If the return value is non-null, it is compared with "true" using String#equalsIgnoreCase(String). If the comparison returns true, this invocation returns true. Otherwise, the original return value is compared with "false", again using String#equalsIgnoreCase(String). If the comparison returns true, this invocation returns false. Otherwise, this invocation returns def.

Java documentation for java.util.prefs.AbstractPreferences.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