public void PushSettings(SettingsDTO settingsDTO) { var prefs = Application.Context.GetSharedPreferences("MyApp", FileCreationMode.Private); var prefEditor = prefs.Edit(); prefEditor.PutString("PrefName", "Some value"); prefEditor.Commit(); }
public void GetSettings(SettingsDTO settingsDto) { var prefs = Application.Context.GetSharedPreferences("AlarmApp", FileCreationMode.Private); settingsDto.WakeUpSound = prefs.GetString("WakeUpSound", string.Empty); settingsDto.AlarmWeekDays = new List<string>(); //prefs.GetString("AlarmWeekDays", null); TODO settingsDto.ShiftFromRunRiseTimeInMins = Convert.ToInt32(prefs.GetString("ShiftFromRunRiseTimeInMins", "0")); settingsDto.SnoozeMins = Convert.ToInt32(prefs.GetString("SnoozeMins", "0")); settingsDto.SoundVolume = Convert.ToInt32(prefs.GetString("SoundVolume", "0")); }
public void PushSettings(SettingsDTO settingsDto) { var prefs = Application.Context.GetSharedPreferences("AlarmApp", FileCreationMode.Private); var prefEditor = prefs.Edit(); prefEditor.PutString("WakeUpSound", settingsDto.WakeUpSound); prefEditor.PutString("AlarmWeekDays", settingsDto.AlarmWeekDays.ToString()); // TODO replace .ToString to proper realization prefEditor.PutString("ShiftFromRunRiseTimeInMins", settingsDto.ShiftFromRunRiseTimeInMins.ToString(CultureInfo.InvariantCulture)); prefEditor.PutString("SnoozeMins", settingsDto.SnoozeMins.ToString(CultureInfo.InvariantCulture)); prefEditor.PutString("SoundVolume", settingsDto.SoundVolume.ToString(CultureInfo.InvariantCulture)); prefEditor.Commit(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var button = FindViewById<Button>(Resource.Id.button1); // TODO #region Getting settings _settingsWorker = new SettingsWorker(); AppSettings = new SettingsDTO(); _settingsWorker.GetSettings(AppSettings); #endregion InitializeLocationManager(); DateTime date = DateTime.Today; bool isSunrise = false; bool isSunset = false; DateTime sunrise = DateTime.Now; DateTime sunset = DateTime.Now; button.Text = AppSettings.WakeUpSound; button.Click += (sender, args) => { /*if (_currentLocation == null) { button.Text = "no location data"; return; }*/ AppSettings.WakeUpSound = "123" + DateTime.Now.ToString(); _settingsWorker.PushSettings(AppSettings); /*SunTimes.Instance.CalculateSunRiseSetTimes(_currentLocation.Latitude, _currentLocation.Longitude, date, ref sunrise, ref sunset, ref isSunrise, ref isSunset); button.Text = string.Format("Sunrise " + sunrise.ToString("HH:mm"));*/ }; }
public void GetSettings(SettingsDTO settingsDTO) { var prefs = Application.Context.GetSharedPreferences("MyApp", FileCreationMode.Private); var somePref = prefs.GetString("PrefName", null); }