[英]Windows Phone 7, IsolatedStorageSettings “Remove()” not working, a bug?
I'm using IsolatedStorageSettings class in my Windows Phone 7 project as a key-value store to remember user preferences and login credentials in my app.我在我的 Windows Phone 7 项目中使用IsolatedStorageSettings class 作为键值存储来记住我的应用程序中的用户首选项和登录凭据。
The problem is, when I invoke Remove(string)
method with the key and then I use Save()
method to persist changes.问题是,当我使用密钥调用
Remove(string)
方法,然后我使用Save()
方法来持久化更改时。 Remove()
method returns true
, that means value is deleted. Remove()
方法返回true
,这意味着值被删除。 But when I try to get the value next time, I see that it is still there and not deleted.但是当我下次尝试获取该值时,我看到它仍然存在并且没有被删除。
Here's the code I use for deletion:这是我用于删除的代码:
if (isolatedStore.Contains(key))
{
isolatedStore[key] = null;
}
bool del = isolatedStore.Remove(key);
isolatedStore.Save();
Here's how I get isolatedStorage
instance:以下是我如何获取
isolatedStorage
实例:
private IsolatedStorageSettings isolatedStore =
IsolatedStorageSettings.ApplicationSettings;
Where do you think the problem is?你认为问题出在哪里?
I found this block in the following link.我在以下链接中找到了这个块。 I haven't tried to remove a key the way you're doing, though.
不过,我没有尝试按照您的方式删除密钥。 http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/17514c94-1f59-47b4-bb78-99694bfbb6b2
http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/17514c94-1f59-47b4-bb78-99694bfbb6b2
public static void DeleteObject(string key)
{
IsolatedStorageSettings.ApplicationSettings.Remove(key);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.