Compartilhar via


ISharedPreferences.GetString(String, String) Method

Definition

Retrieve a String value from the preferences.

[Android.Runtime.Register("getString", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "GetGetString_Ljava_lang_String_Ljava_lang_String_Handler:Android.Content.ISharedPreferencesInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public string? GetString (string? key, string? defValue);
[<Android.Runtime.Register("getString", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "GetGetString_Ljava_lang_String_Ljava_lang_String_Handler:Android.Content.ISharedPreferencesInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member GetString : string * string -> string

Parameters

key
String

The name of the preference to retrieve.

defValue
String

Value to return if this preference does not exist.

Returns

Returns the preference value if it exists, or defValue. Throws ClassCastException if there is a preference with this name that is not a String.

Attributes

Exceptions

Remarks

Retrieve a String value from the preferences.

Java documentation for android.content.SharedPreferences.getString(java.lang.String, 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