次の方法で共有


Preferences.GetLong(String, Int64) Method

Definition

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

[Android.Runtime.Register("getLong", "(Ljava/lang/String;J)J", "GetGetLong_Ljava_lang_String_JHandler")]
public abstract long GetLong (string? key, long def);
[<Android.Runtime.Register("getLong", "(Ljava/lang/String;J)J", "GetGetLong_Ljava_lang_String_JHandler")>]
abstract member GetLong : string * int64 -> int64

Parameters

key
String

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

def
Int64

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

Returns

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

Attributes

Exceptions

if this node has been removed.

if the parameter key is null.

Remarks

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

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

Java documentation for java.util.prefs.Preferences.getLong(java.lang.String, long).

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