我正在开发中的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;
}