当前位置: 首页>>代码示例>>C#>>正文


C# ISharedPreferences.GetString方法代码示例

本文整理汇总了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();
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:31,代码来源:Settings.cs

示例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);
 }
开发者ID:t-denis,项目名称:CiscoWLC.WebAuth.Client,代码行数:8,代码来源:OtherSettings.cs

示例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 ();
 }
开发者ID:Screech129,项目名称:MovieApp,代码行数:13,代码来源:SettingsFragment.cs

示例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();
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:27,代码来源:PreferencesScreen.cs

示例5: OnCreate

        public override void OnCreate ()
        {
            base.OnCreate ();

            prefs = GetSharedPreferences (USER_PREFS, FileCreationMode.Private);
            userName = prefs.GetString (KEY_USERNAME, null);
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:7,代码来源:BikestoreApplication.cs

示例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);
			};
		}
开发者ID:YourmumisEZ,项目名称:WTG,代码行数:27,代码来源:FilterActivity.cs

示例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;
 }
开发者ID:sschocke,项目名称:JGCompanion,代码行数:10,代码来源:MyPreferencesFragment.cs

示例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)
     };
 }
开发者ID:samiy-xx,项目名称:KeySndr.Clients,代码行数:11,代码来源:AndroidAppPreferences.cs

示例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();
				}
			};
		
			} 
开发者ID:YourmumisEZ,项目名称:WTG,代码行数:52,代码来源:MainActivity.cs

示例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;
			}
		}
开发者ID:YourmumisEZ,项目名称:WTG,代码行数:38,代码来源:SearchActivity.cs

示例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));

		}
开发者ID:javiersantos,项目名称:WhatsAppBetaUpdater.Xamarin,代码行数:14,代码来源:SettingsActivity.cs

示例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);
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:48,代码来源:PreferencesScreen.cs

示例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);
            };

        }
开发者ID:piotreqm,项目名称:JedzmyRazem,代码行数:20,代码来源:MyFriendsActivity.cs

示例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();
			}
		}
开发者ID:jonny65,项目名称:WF.Player.Android,代码行数:39,代码来源:Main.cs

示例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;
        }
开发者ID:codesharp,项目名称:cooper,代码行数:23,代码来源:CookieManager.cs


注:本文中的ISharedPreferences.GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。