다음을 통해 공유


Windows Phone Storing string in Application Setting

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!!!