Udostępnij za pośrednictwem


Preferences.GetFloat(String, Single) Method

Definition

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

[Android.Runtime.Register("getFloat", "(Ljava/lang/String;F)F", "GetGetFloat_Ljava_lang_String_FHandler")]
public abstract float GetFloat (string? key, float def);
[<Android.Runtime.Register("getFloat", "(Ljava/lang/String;F)F", "GetGetFloat_Ljava_lang_String_FHandler")>]
abstract member GetFloat : string * single -> single

Parameters

key
String

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

def
Single

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 float, or the backing store is inaccessible.

Returns

the float 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 float.

Attributes

Exceptions

if this node has been removed.

if the parameter key is null.

Remarks

Returns the float value represented by the string associated with the specified key in this preference node. The string is converted to an integer as by Float#parseFloat(String). Returns the specified default if there is no value associated with the key, the backing store is inaccessible, or if Float.parseFloat(String) would throw a NumberFormatException if the associated value were passed. This method is intended for use in conjunction with #putFloat.

If the implementation supports stored defaults and such a default exists, is accessible, and could be converted to a float with Float.parseFloat, this float is returned in preference to the specified default.

Java documentation for java.util.prefs.Preferences.getFloat(java.lang.String, float).

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