为应用程序的整个存在启用的变量
我正在寻找一种方法来存储应用程序的整个现有变量(应用程序上次刷新的日期),相当于 Objective-C iOS 中的 userDefaults 。
我想我可以使用isolatedStorage,但考虑到我只想存储一个变量(日期字符串)并且为此创建一个文件似乎不是最短的方法,它似乎不是最好的选择。
I am looking for a way to store a variable for the entire existante of the app (the date when the app was last refreshed) , an equivalent of the userDefaults
in objective-c iOS.
I was thinking that i could use isolatedStorage, but it doesn't seem to be the best option considering that i am looking to store only one variable (a date string) and creating a file just for that doesn't seem like the shortest way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以这样做
isolatedStorageSettings.ApplicationSettings
检查这篇文章
Windows Phone 7 配置/appSettings?
you can do this
IsolatedStorageSettings.ApplicationSettings
check this post
Windows phone 7 config / appSettings?
如果您没有全局视图模型(或等效模型),您可以向
App
类添加一个属性来存储它。If you don't have a global view model (or equivalent) you could add a propety to the
App
class to store this.即使应用程序完全关闭,您是否需要它仍然存在?如果是这样,那么您将需要使用IsolatedStorage。如果您只在应用程序运行时需要它,那么可以全局访问的类的静态属性就可以了。
Do you need it to persist even when the application is completely shut down? If so, then you will need to use IsolatedStorage. If you only need it while the app is running then a static property of a class that is accessible globally would be fine.