本文整理汇总了C#中ISharedPreferences.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# ISharedPreferences.GetString方法的具体用法?C# ISharedPreferences.GetString怎么用?C# ISharedPreferences.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISharedPreferences
的用法示例。
在下文中一共展示了ISharedPreferences.GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Settings
public Settings(ISharedPreferences preferences, string systemLanguage, InfobaseManager.Infobase infobase)
{
_preferences = preferences;
Language = systemLanguage;
_name = infobase.Name;
BaseUrl = infobase.BaseUrl;
ApplicationString = infobase.ApplicationString;
FtpPort = infobase.FtpPort;
string lastUrl = _preferences.GetString("url", string.Empty);
if (BaseUrl == lastUrl)
{
UserName = _preferences.GetString("user", infobase.UserName);
Password = _preferences.GetString("password", infobase.Password);
}
else
{
UserName = infobase.UserName;
Password = infobase.Password;
}
ClearCacheOnStart = infobase.IsActive && _preferences.GetBoolean("clearCache", ForceClearCache);
infobase.IsActive = true;
infobase.IsAutorun = true;
WriteSettings();
}
示例2: OtherSettings
internal OtherSettings(ISharedPreferences sharedPrefs)
{
ConnectTimeout = int.Parse(sharedPrefs.GetString("pref_timeout_connect", "10000"));
ConnectCheckInterval = int.Parse(sharedPrefs.GetString("pref_interval_check_connect", "200"));
ToastLevel = (ToastLevel)int.Parse(sharedPrefs.GetString("pref_toasts_level", "2"));
IgnoreSslCertErrors = sharedPrefs.GetBoolean("pref_ignore_ssl_errors", true);
StartUrl = sharedPrefs.GetString("pref_start_url", null);
}
示例3: OnSharedPreferenceChanged
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
{
Preference pref = FindPreference (key);
if (pref.GetType () == typeof(ListPreference)) {
var listPref = (ListPreference)pref;
pref.Summary = listPref.Entry;
} else {
pref.Summary = sharedPreferences.GetString (key,"");
}
var prefEditor = sharedPreferences.Edit ();
prefEditor.PutString (key,sharedPreferences.GetString (key,""));
prefEditor.Commit ();
}
示例4: OnSharedPreferenceChanged
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
{
if (key != "clearCache" && key != "anonymousAccess")
{
string value = sharedPreferences.GetString(key, string.Empty);
FillSummary(key, value);
if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true))
{
ISharedPreferencesEditor editor = sharedPreferences.Edit();
editor.PutBoolean("clearCache", true);
editor.Commit();
MakeToast(D.NEED_TO_REBOOT_FULL);
}
if (key == "application")
MakeToast(D.NEED_TO_REBOOT);
}
else
{
MakeToast(D.NEED_TO_REBOOT_FULL);
}
BitBrowserApp.Current.SyncSettings();
}
示例5: OnCreate
public override void OnCreate ()
{
base.OnCreate ();
prefs = GetSharedPreferences (USER_PREFS, FileCreationMode.Private);
userName = prefs.GetString (KEY_USERNAME, null);
}
示例6: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView(Resource.Layout.Filter);
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
RadioButton radio_gps = FindViewById<RadioButton>(Resource.Id.radioButton1);
RadioButton radio_fb = FindViewById<RadioButton>(Resource.Id.radioButton2);
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
string localizationSetting = prefs.GetString("localization","");
if (localizationSetting == "facebook") {
radio_fb.Checked = true;
radio_gps.Checked = false;
}
else
{
radio_fb.Checked = false;
radio_gps.Checked = true;
}
radio_gps.Click += RadioButtonClick;
radio_fb.Click += RadioButtonClick;
Button backButton = FindViewById<Button>(Resource.Id.button1);
backButton.Click += (object sender, EventArgs e) => {
Intent intent = new Intent (this, typeof(MainActivity));
StartActivityForResult (intent, 0);
};
}
示例7: DisplayCurrentPreferenceValues
void DisplayCurrentPreferenceValues(ISharedPreferences sharedPreferences)
{
Preference pilotName = FindPreference("pref_pilotname");
string curPilotName = sharedPreferences.GetString("pref_pilotname", "");
if (curPilotName == "")
{
curPilotName = "Enter your pilot name";
}
pilotName.Summary = curPilotName;
}
示例8: Create
public static AppPreferences Create(ISharedPreferences prefs)
{
return new AndroidAppPreferences(prefs)
{
FirtsTimeRunning = prefs.GetBoolean(AppPreferences.FirstTimeKey, true),
Ip = prefs.GetString(AppPreferences.IpKey, ""),
Port = prefs.GetInt(AppPreferences.PortKey, 0),
UseSounds = prefs.GetBoolean(AppPreferences.UseSoundsKey, true),
UseCache = prefs.GetBoolean(AppPreferences.UseCacheKey, true)
};
}
示例9: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
ConnectivityManager connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService);
NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo;
Button loginButton = FindViewById<Button>(Resource.Id.loginButton);
Button filteButton = FindViewById<Button> (Resource.Id.button1);
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
_locationManager = GetSystemService (Context.LocationService) as LocationManager;
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
filteButton.Click += (object sender, EventArgs e) => {
Intent intent = new Intent (this, typeof(FilterActivity));
StartActivityForResult (intent, 0);
};
loginButton.Click += (object sender, EventArgs e) => {
bool isOnline = (activeConnection != null) && activeConnection.IsConnected;
bool wifiIsOnline = (connectivityManager.GetNetworkInfo(ConnectivityType.Wifi)).IsConnected;
if (isOnline || wifiIsOnline) {
if (!string.IsNullOrEmpty (prefs.GetString ("token", ""))) {
Intent intent = new Intent (this, typeof(SearchActivity));
StartActivityForResult (intent, 0);
} else {
auth = Global.LogIn ();
auth.Completed += auth_Completed;
StartActivity (auth.GetUI (this));
}
}
else
{
AlertDialog.Builder alert = new AlertDialog.Builder (this);
alert.SetTitle ("Internet connection error");
alert.SetMessage ("Turn wifi or mobile data on");
alert.SetPositiveButton ("Ok", (senderAlert, args) => {
});
Dialog dialog = alert.Create();
dialog.Show();
}
};
}
示例10: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
try
{
base.OnCreate (savedInstanceState);
SetContentView(Resource.Layout.Search);
loading = FindViewById<TextView>(Resource.Id.textView1);
pBar = FindViewById<ProgressBar>(Resource.Id.searchPB);
pBar.Visibility = ViewStates.Visible;
loading.Visibility = ViewStates.Visible;
loading.Text="Loading events";
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
string token = prefs.GetString("token","");
localizationSetting = prefs.GetString("localization","");
if (localizationSetting == "gps" && Global.GPSCoords == null)
{
AlertDialog.Builder alert = new AlertDialog.Builder (this);
alert.SetTitle ("GPS error");
alert.SetMessage ("Turn gps on");
alert.SetPositiveButton ("Ok", (senderAlert, args) =>
{
Intent intent = new Intent (this, typeof(MainActivity));
StartActivityForResult (intent, 0);
}
);
Dialog dialog = alert.Create ();
dialog.Show ();
}
else
{
GetPlacesList (token,localizationSetting);
}
}
catch(Exception ex)
{
throw ex;
}
}
示例11: OnCreate
protected override void OnCreate (Bundle bundle) {
base.OnCreate (bundle);
AddPreferencesFromResource (Resource.Layout.settings_prefs);
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
prefs.RegisterOnSharedPreferenceChangeListener(this);
prefVersion = FindPreference ("prefVersion");
prefVersion.Title = Resources.GetString(Resource.String.app_name) + " v" + ApplicationContext.PackageManager.GetPackageInfo (ApplicationContext.PackageName, 0).VersionName + " (" + ApplicationContext.PackageManager.GetPackageInfo (ApplicationContext.PackageName, 0).VersionCode + ")";
prefHoursNotifications = FindPreference ("prefHoursNotifications");
prefHoursNotifications.Summary = string.Format (Resources.GetString (Resource.String.settings_interval_description), Resources.GetStringArray(Resource.Array.hours).GetValue(int.Parse(prefs.GetString ("prefHoursNotifications", "4"))-1));
}
示例12: OnSharedPreferenceChanged
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
{
string value = string.Empty;
if (key != "clearCache" && key != "anonymousAccess")
{
Preference preference = (Preference)FindPreference(key);
value = sharedPreferences.GetString(key, string.Empty);
FillSummary(key, value);
if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true))
{
ISharedPreferencesEditor editor = sharedPreferences.Edit();
editor.PutBoolean("clearCache", true);
editor.Commit();
Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show();
}
if (key == "application")
{
Toast.MakeText(this, D.NEED_TO_REBOOT, ToastLength.Long).Show();
}
}
else
{
if (key == "anonymousAccess")
{
string user = "";
string password = "";
if (sharedPreferences.GetBoolean("anonymousAccess", false))
{
user = Settings.AnonymousUserName;
password = Settings.AnonymousPassword;
}
ISharedPreferencesEditor editor = sharedPreferences.Edit();
editor.PutString("user", user);
editor.PutString("password", password);
editor.Commit();
}
Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show();
}
BitBrowserApp.Current.SyncSettings(true);
}
示例13: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MyFriends);
preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
token = JsonConvert.DeserializeObject<AuthenticationToken>(preferences.GetString("token", null));
mAddFriendButton = FindViewById<ImageButton>(Resource.Id.addFriendImageButton);
mMyFriendsList = FindViewById<ListView>(Resource.Id.MyFriendsListView);
mItems = new List<FriendListItem>();
RegisterForContextMenu(mMyFriendsList);
GetMyFriends();
mAddFriendButton.Click += (object sender, EventArgs e) =>
{
StartActivityForResult(typeof(FindFriendToAddActivity), 2);
};
}
示例14: MainApp
public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
// Save instance for later use
instance = this;
TestFlight.TakeOff(this, "0596e62a-e3cb-4107-8d05-96fa7ae0c26a");
// Catch unhandled exceptions
// Found at http://xandroid4net.blogspot.de/2013/11/how-to-capture-unhandled-exceptions.html
// Add an exception handler for all uncaught exceptions.
AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionHandler;
AppDomain.CurrentDomain.UnhandledException += ApplicationUnhandledExceptionHandler;
preferences = Application.Context.GetSharedPreferences("WF.Player.preferences", FileCreationMode.MultiProcess);
path = preferences.GetString("path", "");
if (String.IsNullOrEmpty(path))
path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + Java.IO.File.Separator + "WF.Player";
try {
if (!Directory.Exists (path))
Directory.CreateDirectory (path);
}
catch {
}
if (!Directory.Exists (path))
{
AlertDialog.Builder builder = new AlertDialog.Builder (this);
builder.SetTitle (GetString (Resource.String.main_error));
builder.SetMessage(String.Format(GetString(Resource.String.main_error_directory_not_found), path));
builder.SetCancelable (true);
builder.SetNeutralButton(Resource.String.ok,(obj,arg) => { });
builder.Show ();
} else {
preferences.Edit().PutString("path", path).Commit();
}
}
示例15: GetCookie
public static Cookie GetCookie(ISharedPreferences sharedPreferences, string cookieKey)
{
var cookieString = sharedPreferences.GetString(cookieKey, null);
if (!string.IsNullOrEmpty(cookieString))
{
var cookie = new Cookie();
var entries = cookieString.Split('|');
var cookieType = typeof(Cookie);
foreach (var entry in entries)
{
var index = entry.IndexOf(':');
var propertyName = entry.Substring(0, index);
var propertyValue = entry.Substring(index + 1);
var property = cookieType.GetProperty(propertyName);
property.SetValue(cookie, Utils.ConvertType(propertyValue, property.PropertyType), null);
}
return cookie;
}
return null;
}