Windows Phone Storing string in Application Setting

Windows Phone Storing string in Application Setting

Rate This
  • Comments 0

For small key-value pair like storage we can use Application Setting and store the string. It is simple and easy to retrieve.

// Storing the data in Application Settings
private void btnSave_Click(object sender, RoutedEventArgs e)
{
    IsolatedStorageSettings.ApplicationSettings["TheName"] = txtName.Text;
    IsolatedStorageSettings.ApplicationSettings.Save(); //Important to call to Save it
}

//Getting the data from Application Settings
private void btnRead_Click(object sender, RoutedEventArgs e)
{
    if(IsolatedStorageSettings.ApplicationSettings.Contains("TheName"))
    {
        txtRead.Text = (string)IsolatedStorageSettings.ApplicationSettings["TheName"];

        //To remove 
        IsolatedStorageSettings.ApplicationSettings.Remove("TheName");
    }            
}
  

Namoskar!!!

Leave a Comment
  • Please add 7 and 4 and type the answer here:
  • Post