关于android中的SharedPreferences

发布于 2024-09-10 22:55:04 字数 89 浏览 2 评论 0原文

我只是想知道,如果我想重置与 SharedPreferences 一起使用的实际首选项文件,我可以重命名首选项文件吗? ,这不是意味着该文件 仍然存在还是会覆盖它?

i was just wondering, if i wanted to reset the actual preference file used with SharedPreferences could i just rename the preference file ? , wouldn't that mean that the file
still exist or does overwrite it ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城旧梦 2024-09-17 22:55:04
prefs.edit().clear().commit(); // prefs = SharedPreferences

才是正确的方法。删除没有引用 SharedPreferences 对象的文件应该会产生相同的结果。

prefs.edit().clear().commit(); // prefs = SharedPreferences

is the proper way. Deleting the file with no referencing SharedPreferences objects should result the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文