Skip to content

Instantly share code, notes, and snippets.

@wtuts
Created June 26, 2014 18:56
Show Gist options
  • Save wtuts/c5c9c590575472f3ae06 to your computer and use it in GitHub Desktop.
Save wtuts/c5c9c590575472f3ae06 to your computer and use it in GitHub Desktop.
Isolated Storage
//For single object data such as string
private void Save_single_object_button_click(object sender, RoutedEventArgs e)
{
//Declare the instance of Isolated Storage settings
var settings = IsolatedStorageSettings.ApplicationSettings;
//add a key value pair with key name and value chetan
settings.Add("name", "Chetan");
//add a key value pair with key marks and value 100
settings.Add("marks", 100);
}
//Note:Just click on the above save button once because every time you click on it a error will occur
//Because the value of each Key pair must be unique
private void Read_single_object_button_click(object sender, RoutedEventArgs e)
{
//Declare the instance of Isolated Storage settings
var settings = IsolatedStorageSettings.ApplicationSettings;
string Name="", Marks="";
//check if target object exists with specific key value
if (settings.Contains("name"))
{
Name = settings["name"].ToString();
}
if (settings.Contains("marks"))
{
Marks = settings["marks"].ToString();
Displayblock.Text = "Name of student is " + Name + " and Marks are " + Marks;
}
else
{
Displayblock.Text = "First save the values to isolated Storage.Click on the save button.";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment