Q:

Set a default value only for the first access

In the MainPage.xam there is a PasswordBox, if you insert the right password, you can access to Address.xaml.
The password (a string called masterpass) is set to "0000" and there is an option to change it, but everytime the app is opened, password is set to "0000" again
What i'm doing wrong?
Here is the code:
public partial class MainPage : PhoneApplicationPage
{
    // Constructor
    private string masterpass ="0000";
    public MainPage()
    {
        InitializeComponent();
    }

    private void CustomersButton_Click(object sender, RoutedEventArgs e)
    {
        if (String.Compare(inizio.Password, masterpass)==0)
        {
            NavigationService.Navigate(new Uri("/Address.xaml", UriKind.Relative));
        }
        else
        {
            MessageBox.Show("Wrong password, please try again", "Error", MessageBoxButton.OK);
        }
    }

    private void Save_Click(object sender, RoutedEventArgs e)
    {
        if (String.Compare(vecchio.Password, masterpass) == 0)
        {
            if (String.Compare(newmaster.Password, repeatmaster.Password) == 0)
            {
                masterpass = newmaster.Password;
                MessageBox.Show("Password changed", "Confirmation", MessageBoxButton.OK);
            }
            else
            {
                MessageBox.Show("New password doesn't match confirmation", "Error", MessageBoxButton.OK);
            }
        }
        else
        {
            MessageBox.Show("Wrong master password, please try again", "Error", MessageBoxButton.OK);
        }
    }
}

Thanks everyone

A:

masterpass is just a variable in your application that is reset every single time you restart your program. If you want to persist the value you can use IsolatedStorageSettings. There's a great quickstart which I'd recommend that you read, but in the meanwhile you could add code like:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

// Constructor

public MainPage()
{
    InitializeComponent();

    if (!settings.Contains("masterPass"))
    {
        // set a default
        settings.Add("masterPass", "0000");
        settings.Save();
    }
}

Then, whenever you want to use masterPass use settings["masterPass"]. Don't forget to call Save() when you change the value. This is a really quick intro (and not the cleanest code) but the quickstart will point you in the right direction.    

