Posted By

vhdm on 08/03/14


Tagged

phone windows save settings wp8 vhdm vahid mahmoudian


Versions (?)

Window Phone Save Settings


 / Published in: C#
 

for save settings in windows phone

  1. private static string key(string type, string key = "", string value = "")
  2. {
  3. string ret = string.Empty;
  4. IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
  5. try
  6. {
  7. switch (type)
  8. {
  9. case "add":
  10. settings.Add(key, value);
  11. settings.Save();
  12. return "success";
  13. case "remove":
  14. if (settings.Contains(key))
  15. {
  16. settings.Remove(key);
  17. settings.Save();
  18. return "success";
  19. }
  20. else return "error";
  21. case "update":
  22. if (settings.Contains(key))
  23. {
  24. settings[key] = value;
  25. settings.Save();
  26. return "success";
  27. }
  28. else return "error";
  29. case "select":
  30. if (settings.Contains(key))
  31. return settings[key] as string;
  32. return "error";
  33. case "is_key":
  34. if (settings.Contains(key)) return "success";
  35. else return "error";
  36. default:
  37. return "error";
  38. }
  39. }
  40. catch (Exception ex)
  41. {
  42. MessageBox.Show(ex.Message);
  43. return "error";
  44. }
  45. }

Report this snippet  

You need to login to post a comment.