What's the difference between commit() and apply() in SharedPreferences

后端 未结 8 2311
你的背包
你的背包 2020-11-22 10:03

I am using SharedPreferences in my android app. I am using both commit() and apply() method from shared preference. When I use AVD 2.3

8条回答
  •  时光说笑
    2020-11-22 10:11

    Use apply().

    It writes the changes to the RAM immediately and waits and writes it to the internal storage(the actual preference file) after. Commit writes the changes synchronously and directly to the file.

提交回复
热议问题