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


C# ISharedPreferences.Edit方法代码示例

本文整理汇总了C#中ISharedPreferences.Edit方法的典型用法代码示例。如果您正苦于以下问题:C# ISharedPreferences.Edit方法的具体用法?C# ISharedPreferences.Edit怎么用?C# ISharedPreferences.Edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISharedPreferences的用法示例。


在下文中一共展示了ISharedPreferences.Edit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: SaveCookie

        public static void SaveCookie(ISharedPreferences sharedPreferences, string cookieKey, Cookie cookie)
        {
            var editor = sharedPreferences.Edit();
            var cookieValueItems = new List<string>();
            var itemFormat = "{0}:{1}";

            cookieValueItems.Clear();

            cookieValueItems.Add(string.Format(itemFormat, "Domain", cookie.Domain));
            cookieValueItems.Add(string.Format(itemFormat, "Name", cookie.Name));
            cookieValueItems.Add(string.Format(itemFormat, "Value", cookie.Value));
            cookieValueItems.Add(string.Format(itemFormat, "Expires", cookie.Expires.ToString()));
            cookieValueItems.Add(string.Format(itemFormat, "Comment", cookie.Comment));
            cookieValueItems.Add(string.Format(itemFormat, "CommentUri", cookie.CommentUri != null ? cookie.CommentUri.AbsoluteUri : null));
            cookieValueItems.Add(string.Format(itemFormat, "Discard", cookie.Discard));
            cookieValueItems.Add(string.Format(itemFormat, "HttpOnly", cookie.HttpOnly));
            cookieValueItems.Add(string.Format(itemFormat, "Path", cookie.Path));
            cookieValueItems.Add(string.Format(itemFormat, "Port", cookie.Port));
            cookieValueItems.Add(string.Format(itemFormat, "Secure", cookie.Secure));
            cookieValueItems.Add(string.Format(itemFormat, "Version", cookie.Version));

            editor.PutString(cookieKey, string.Join("|", cookieValueItems.ToArray()));
            editor.Commit();

            var logger = DependencyResolver.Resolve<ILoggerFactory>().Create(typeof(CookieManager));
            logger.InfoFormat("Saved Cookie. Domain:{0}, Name:{1}, Value:{2}, Expires:{3}", cookie.Domain, cookie.Name, cookie.Value, cookie.Expires);
        }
开发者ID:codesharp,项目名称:cooper,代码行数:27,代码来源:CookieManager.cs

示例3: 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

示例4: OnSharedPreferenceChanged

        public void OnSharedPreferenceChanged(ISharedPreferences prefs, string key)
        {
            if (key == "listThemeStyle")
            {
                ListPreference lp = (ListPreference)FindPreference(key);
                String lpVal = lp.Value;
                if (lpVal.Contains("Dark"))
                {
                    prefs.Edit().PutInt("ThemeStyle", Resource.Style.Theme_Sherlock).Commit();
                    ThisApp.StyleTheme = Resource.Style.Theme_Sherlock;
                }
                else if (lpVal.Contains("Light"))
                {
                    prefs.Edit().PutInt("ThemeStyle", Resource.Style.Theme_Sherlock_Light).Commit();
                    ThisApp.StyleTheme = Resource.Style.Theme_Sherlock_Light;
                }

                Finish();
                StartActivity(Intent);
            }
            else if (key == "listFontSize")
            {
                ThisApp.Language = ThisApp.Language;
            }
            else if (key == "dualWebviews")
            {
                CheckBoxPreference cbp = (CheckBoxPreference)FindPreference(key);
                if (cbp.Checked)
                {
                    slp.Enabled = true;
                    slp.Selectable = true;
                    slp.SetEntries(ThisApp.DownloadedLanguages.ToArray());
                    slp.SetEntryValues(ThisApp.DownloadedLanguages.ToArray());
                    if (string.IsNullOrEmpty(slp.Value))
                    {
                        slp.SetValueIndex(ThisApp.DownloadedLanguages.IndexOf(ThisApp.Language));
                    }
                }
                else
                {
                    slp.Enabled = false;
                    slp.Selectable = false;
                }
            }
        }
开发者ID:GuyMicciche,项目名称:SuperNWTBible,代码行数:45,代码来源:PreferencesActivity.cs

示例5: StorePreferences

    public void StorePreferences(ISharedPreferences spr)
    {
      var prefsEditor = spr.Edit();

      prefsEditor.PutInt("TableOf", TableOf);
      prefsEditor.PutString("strRandomQuestions", RandomQuestions.ToString());
      prefsEditor.PutInt("UpperLimit", UpperLimit);
      prefsEditor.PutInt("CounterMin", CounterMin);
      prefsEditor.PutInt("CounterMax", CounterMax);
      prefsEditor.Commit();
    }
开发者ID:Xtremrules,项目名称:dot42,代码行数:11,代码来源:Preferences.cs

示例6: 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

示例7: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            Delegate.InstallViewFactory();
            Delegate.OnCreate(bundle);
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.settings);
            var toolbar = FindViewById<Toolbar>(Resource.Id.settings_toolbar);
            SetSupportActionBar(toolbar);
            AddPreferencesFromResource(Resource.Xml.settings);
            SupportActionBar.Title = "Impostazioni";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            toolbar.NavigationClick += delegate (object sender, Toolbar.NavigationClickEventArgs e)
            {
                Finish();
            };

            prefs = Application.Context.GetSharedPreferences ("AndroidReport", FileCreationMode.Private);
            prefsEdit = prefs.Edit();

            Preference deleteCache = (Preference)FindPreference("delete_cache");
            deleteCache.PreferenceClick += DeleteCache_PreferenceClick;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
            {
                SwitchPreference cacheSwitch = (SwitchPreference)FindPreference("allow_cache");
                cacheSwitch.PreferenceChange += CacheSwitch_PreferenceChange;

                SwitchPreference notificationSwitch = (SwitchPreference)FindPreference("allow_notifications");
                notificationSwitch.PreferenceChange += NotificationSwitch_PreferenceChange;

                SwitchPreference animationSwitch = (SwitchPreference)FindPreference("allow_animations");
                animationSwitch.PreferenceChange += AnimationSwitch_PreferenceChange;
            }
            else
            {
                CheckBoxPreference cacheSwitch = (CheckBoxPreference)FindPreference("allow_cache");
                cacheSwitch.PreferenceChange += CacheSwitch_PreferenceChange;

                CheckBoxPreference notificationSwitch = (CheckBoxPreference)FindPreference("allow_notifications");
                notificationSwitch.PreferenceChange += NotificationSwitch_PreferenceChange;

                CheckBoxPreference animationSwitch = (CheckBoxPreference)FindPreference("allow_animations");
                animationSwitch.PreferenceChange += AnimationSwitch_PreferenceChange;
            }
        }
开发者ID:YoDevil,项目名称:SmartReport,代码行数:46,代码来源:Settings.cs

示例8: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Login);

            // Shared preferences file for storing bearer token for whole app - initialization:
            preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            editor = preferences.Edit();

            mEmailField = base.FindViewById<EditText>(Resource.Id.emailField);
            mPassField = base.FindViewById<EditText>(Resource.Id.passField);
            mLoginButton = base.FindViewById<Button>(Resource.Id.loginButton);
            mRegisterButton = base.FindViewById<Button>(Resource.Id.registerButton);
            mForgottenPwButton = base.FindViewById<Button>(Resource.Id.forgottenPwButton);

            mLoginButton.Click += MLoginButton_Click;
            mRegisterButton.Click += MRegisterButton_Click;
            mForgottenPwButton.Click += MForgottenPwButton_Click;
            
        }
开发者ID:piotreqm,项目名称:JedzmyRazem,代码行数:20,代码来源:LoginActivity.cs

示例9: OnCreate

        // metoda wywo³ania na stworzenie widoku
        protected override void OnCreate(Bundle bundle)
        {
            //przypisanie widoku AXML do klasy
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            // Shared preferences file for storing bearer token for whole app - initialization:
            preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            editor = preferences.Edit();

            //przypisanie kontrolek widoku do zmiennych
            mMyMessagesButton = base.FindViewById<ImageButton>(Resource.Id.msgImageButton);
            mFriendsMessagesButton = base.FindViewById<ImageButton>(Resource.Id.friendsMsgImageButton);
            mMyFriendsButton = base.FindViewById<ImageButton>(Resource.Id.friendsImageButton);
            mOtherTravelersButton = base.FindViewById<ImageButton>(Resource.Id.travelersImageButton);
            //metody dla zdarzenia klikniêcia na przycisk
            mMyMessagesButton.Click += MMyMessagesButton_Click;
            mFriendsMessagesButton.Click += MFriendsMessagesButton_Click;
            mMyFriendsButton.Click += MMyFriendsButton_Click;
            mOtherTravelersButton.Click += MOtherTravelersButton_Click;
        }
开发者ID:piotreqm,项目名称:JedzmyRazem,代码行数:22,代码来源:MainActivity.cs

示例10: 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

示例11: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.welcome);

            prefs = GetPreferences (FileCreationMode.Append);
            firstTime = prefs.GetBoolean (FIRST, true);
            if (firstTime) {
                MakeQuestionDB ();
                MakeScoreDB ();
                editor = prefs.Edit ();
                editor.PutBoolean (FIRST, false);
                editor.Commit ();

            }

            Button button = FindViewById<Button> (Resource.Id.btnStarQuiz);
            button.Click += delegate {
                StartActivity (typeof(QuizActivity));
                Finish ();
            };
        }
开发者ID:bny-mobile,项目名称:QuizData,代码行数:22,代码来源:Activity1.cs

示例12: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            userID = Intent.GetStringExtra ("id") ?? "-1";
            mainPrefs = GetSharedPreferences("loginPrefs",FileCreationMode.Private);
            mainEditor = mainPrefs.Edit ();
            serviceNumer = mainPrefs.GetInt ("service_size", -1);
            categoryNumber = mainPrefs.GetInt ("category_size", 0);
            SetContentView (Resource.Layout.Main);

            tabHost = FindViewById<TabHost> (Android.Resource.Id.TabHost);

            tabHost.Setup ();

            for (int i = 0; i < categoryNumber; i++) {

                TabHost.TabSpec tabSpec;
                tabSpec = tabHost.NewTabSpec(mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower());
                tabSpec.SetIndicator(mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower());
                tabSpec.SetContent(new FakeContent(this));
                tabHost.AddTab(tabSpec);
            }
            tabHost.SetOnTabChangedListener(this);
            setSelectedTabColor ();
            /*for(int i = 0; i < tabHost.TabWidget.ChildCount; i++) {
                View v = tabHost.TabWidget.GetChildTabViewAt(i);

                // Look for the title view to ensure this is an indicator and not a divider.

                v.SetBackgroundResource(Resource.Drawable.apptheme_tab_indicator_holo);
            }*/
            viewPager = FindViewById<ViewPager> (Resource.Id.view);
            var adaptor = new ServiceBeaconAdapter (SupportFragmentManager);

            for (int i = 0; i < categoryNumber; i++) {
                adaptor.addFragmentView ((k, v, b) => {
                    var view = k.Inflate (Resource.Layout.Page, v, false);
                    var myText = view.FindViewById<TextView> (Resource.Id.textView1);
                    myText.Text = mainPrefs.GetString ("ServiceCategoriesName_" + i, null).ToLower();
                    return view;
                });
            }

            viewPager.Adapter = adaptor;//new ServiceBeaconAdapter (SupportFragmentManager);
            viewPager.SetOnPageChangeListener(this);

            beaconStatusLabel = FindViewById<TextView> (Resource.Id.beaconStatusLabel);

            beaconMgr.Bind (this);

            //myProcessedBeacons = new JavaDictionary<string,string>();
            monitorNotifier.EnterRegionComplete += EnteredRegion;
            monitorNotifier.ExitRegionComplete += ExitedRegion;

            rangeNotifier.DidRangeBeaconsInRegionComplete += HandleBeaconsInRegion;
        }
开发者ID:slitaiem,项目名称:great-subversion,代码行数:57,代码来源:MainActivity.cs

示例13: OnScrolled

		public override void OnScrolled (RecyclerView recyclerView, int dx, int dy)
		{
			pref = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
			LinearLayoutManager linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager ();
			int lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition();
			int totalItemCount = recyclerView.GetAdapter().ItemCount;

			if (!IsLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
				// End has been reached
				// Do something
				var currPrefPage = pref.GetString ("CurrentPage", string.Empty);
				if (!String.IsNullOrEmpty (currPrefPage)) {
					if (Int32.Parse (currPrefPage) > 0) {
						currentPage++;
					} else {
						currentPage = 2;
					}
				} else {
					currentPage++;

				}
				var editor = pref.Edit();
				editor.PutString("CurrentPage",currentPage.ToString());
				editor.Apply();

				IsLoading = true;
				Task.Factory.StartNew (async () => {
					
					try{
						var newPostList = new List<Post>();
						await WebClient.LoadPosts(newPostList,currentPage);


						(recyclerView.GetAdapter()as PostViewAdapter)._Posts.AddRange(newPostList);
						//recyclerView.GetAdapter().HasStableIds = true;

						_messageShown = false;
						Application.SynchronizationContext.Post (_ => {recyclerView.GetAdapter().NotifyDataSetChanged();}, null);
						//recyclerView.GetAdapter().NotifyItemRangeInserted(recyclerView.GetAdapter().ItemCount,newPostList.Count);
					}catch(Exception ex){
						//Insights.Report(ex,new Dictionary<string,string>{{"Message",ex.Message}},Insights.Severity.Error);
						var text = ex.Message;
						if(!_messageShown){
							Application.SynchronizationContext.Post (_ => {
								Toast.MakeText(Application.Context,"При загрузке данных произошла ошибка",ToastLength.Short).Show();
							}, null);
							_messageShown = true;
						}

					}


					IsLoading = false;
				});

			}
		}
开发者ID:takigava,项目名称:pikabu,代码行数:57,代码来源:PostViewAdapter.cs

示例14: AppConfig

 private AppConfig()
 {
     m_Read=Android.App.Application.Context.GetSharedPreferences("AppSetting", FileCreationMode.Private);
     m_Edit=m_Read.Edit();
 }
开发者ID:tianjing,项目名称:SayWordByPicture,代码行数:5,代码来源:AppConfig.cs

示例15: SettingsService

        public SettingsService()
        {
			_sharedPreferences = Application.Context.GetSharedPreferences(AppConstants.AppName, FileCreationMode.Private);
            _sharedPreferencesEditor = _sharedPreferences.Edit();
        }
开发者ID:Vineland,项目名称:DarkestNight.App,代码行数:5,代码来源:SettingsService.cs


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