我正在開發中的Windows Phone 8 一個應用程序,我需要一些小的數據存儲(排行榜在我的情況)獨立存儲不存儲數據時,應用程序退出
該應用程序是關於一個數學遊戲,其中有一個計時器 當我完成遊戲,高分更新,並且即使我導航回並重新導航到頁面高分領域仍然顯示保存的高分,這是偉大的
問題是當我退出應用程序並重新打開它,高分重置.. 我不知道爲什麼
我的代碼:
IsolatedStorageSettings highScoreSettings = IsolatedStorageSettings.ApplicationSettings;
public void TimeLeftTick(Object sender, EventArgs args)
{
prog1.Value-=10;
//GAME ENDS
if (prog1.Value == 0)
{
//If there is already a highscore saved
if(highScoreSettings.Contains("highscore"))
if (Score > Convert.ToInt32(highScoreValue.Text))
{
highScoreSettings.Remove("highscore"); // remove highscore
highScoreSettings.Add("highscore", Score.ToString()); // update highscore
highScoreValue.Text = highScoreSettings["highscore"].ToString();
}
MessageBox.Show("Time is out");
TimeLeft.Stop();
prog1.Value = 100;
return;
}
// LOAD DATA
private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
{
if (IsolatedStorageSettings.ApplicationSettings.Contains("highscore"))
highScoreValue.Text = IsolatedStorageSettings.ApplicationSettings["highscore"] as string;
}