共享首选项中的 put 方法之前会调用remove吗?
我试图弄清楚方法remove(String name)是否真的在放置之前执行。
例如,使用以下代码:
//String
String newString = "This is a string";
editor.putString("newString", newString);
editor.remove("newString");
editor.commit();
key newString 不会出现在共享首选项中,但使用以下代码:
//String
String newString = "This is a string";
editor.putString("newString", newString);
editor.clear();
editor.commit();
key newString 将出现在共享首选项中。
谁能给我一个例子来说明remove方法将在put方法之前执行?
I am trying to figure out if the method remove(String name) really execute before put.
For example, with the follow code:
//String
String newString = "This is a string";
editor.putString("newString", newString);
editor.remove("newString");
editor.commit();
The key newString won't appears in the Shared Preferences, but with the follow code:
//String
String newString = "This is a string";
editor.putString("newString", newString);
editor.clear();
editor.commit();
The key newString will appears in the Shared preferences.
Can anyone give me an example in which shows that the method remove will be execute before the put method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论