windows-phone-7 – 使用本地数据库在Windows Phone 7中保存变量
发布时间:2021-02-06 17:45:07 所属栏目:系统 来源:网络整理
导读:如何在 Windows Phone 7中使用本地数据库只保存一个值,然后在每次加载(打开)应用程序时检索该值? 解决方法 如果您只想存储一个值进行检索,那么我建议使用IsolatedStorage,尤其是ApplicationSettings类. 它的用法示例: using System.IO.IsolatedStorage;//s
如何在 Windows Phone 7中使用本地数据库只保存一个值,然后在每次加载(打开)应用程序时检索该值? 解决方法如果您只想存储一个值进行检索,那么我建议使用IsolatedStorage,尤其是ApplicationSettings类.它的用法示例: using System.IO.IsolatedStorage; //storing value int someValue = 10; IsolatedStorageSettings.ApplicationSettings.Add("MyKey",someValue); //write or update value IsolatedStorageSettings.ApplicationSettings["MyKey"] = someValue; //write to disk IsolatedStorageSettings.ApplicationSettings.Save(); //reading value if(IsolatedStorageSettings.ApplicationSettings.Contains("MyKey")) { int readValue = (int) IsolatedStorageSettings.ApplicationSettings["MyKey"]; } 芒果现在提供MSSqlCE支持,但对于一组值,它是过度的.如果需要存储关系数据,则数据库更合适,而不是持久化用户/应用程序设置. 虽然IsolatedStorage很好,但读取和写入的成本可能很高.避免从UI线程中读取IsolatedStorage,这会导致您的应用看起来没有响应. (编辑:瑞安网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐
热点阅读