删除一些SharedPreferences [英] Remove some SharedPreferences
本文介绍了删除一些SharedPreferences的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一个简单的大幅削减游戏,我正在保存黄金之类的东西在 SharedPreferences
中.如何从 SharedPreferences
中将其删除但仍然可以调用黄金的价值,例如Temple运行2游戏.
I am making a simple slashing game and I am saving stuffs like gold
in SharedPreferences
. How to remove it from SharedPreferences
but still be able to call the value of the gold,like Temple run 2 game.
推荐答案
要删除特定值: SharedPreferences.Editor.remove()
后跟 commit()
要删除所有 SharedPreferences.Editor.clear()
,然后是 commit()
如果您不关心返回值,而是在应用程序的主线程中使用此值,请考虑改为使用apply().
If you don't care about the return value and you're using this from your application's main thread, consider using apply() instead.
这篇关于删除一些SharedPreferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文