Windows Phone 8 ApplicationSettings - Get settings in Universal app

本小妞迷上赌 提交于 2019-12-21 05:36:07

问题


I'm upgrading windows phone 8 application. I created Universal app (Windows.Phone 8.1).

The settings in old WP8.0 application are saved in following way:

IsolatedStorageSettings.ApplicationSettings.Add("MY_SETTINGS", value);

Question: How can i get this settings when app is upgraded to WP8.1 (Universal app).

I try the following:

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
var isContains1 = localSettings.Values.ContainsKey("MY_SETTINGS");
var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
var isContains2 = roamingSettings.Values.ContainsKey("MY_SETTINGS");

But no "MY_SETTINGS" are found. (isContains1, isContains2 == false):\

Many Thanks for help


回答1:


LocalSettings in WP8.1 works differently than those in WP8.0 - where settings were saved in a file (after serialization). The file is __ApplicationSettings - take a look at it (via IS explorer tool) and you will see its structure - part of it is a serialized dictionary. I've made some research once, which showed that all the old files are preserved during the update - which means that the settings are still there.

Once you update your WP8.0 app to WP8.1 and you want to read your old settings, you can retrive the values from the file.




回答2:


This blog post has your exact answer, including the code needed to deserialize the migrated settings file!




回答3:


You can use ApplicationData.LocalSettings It would Get you the application settings container in the local app data store. here is a Dev center link in which its Described how to use it.



来源:https://stackoverflow.com/questions/25113478/windows-phone-8-applicationsettings-get-settings-in-universal-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!