gpt4 book ai didi

android - SharedPreferences.Editor commit() 是只写回所做的更改,还是写回整组首选项?

转载 作者:行者123 更新时间:2023-11-29 00:37:38 24 4
gpt4 key购买 nike

当您在 SharedPreferences.Editor 上调用提交时,它是否只写回是否已更改,或者它是否也写回其链接的 SharedPreference 对象中的所有值,无论它们是否已更改?

最佳答案

来自 the documentation :

Commit your preferences changes back from this Editor to the SharedPreferences object it is editing. This atomically performs the requested modifications, replacing whatever is currently in the SharedPreferences.

这似乎表明数据只是被修改,如果相同则不会被覆盖。但请记住,多次调用 commit() 只会产生一个更改(最后一个)。

关于android - SharedPreferences.Editor commit() 是只写回所做的更改,还是写回整组首选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11603046/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com