当前位置:网站首页>Have you replaced commit() with sharedprefrence's apply()?
Have you replaced commit() with sharedprefrence's apply()?
2022-04-21 18:11:00 【InfoQ】
commit()commit()
commit() and apply() What are the similarities and differences ?
- Both are submitted Prefrence Modifying data ;
- Both are atomic processes .
commit()- Commit your preferences changes back from this Editor to the
- {@link SharedPreferences} object it is editing. This atomically
- performs the requested modifications, replacing whatever is currently
- in the SharedPreferences.
- <p>Note that when two editors are modifying preferences at the same
- time, the last one to call commit wins.
- <p>If you don't care about the return value and you're
- using《Android Summary of learning notes + Latest mobile architecture video + Big Android interview questions + Project actual combat source code handout 》 Open sourcethis from your application's main thread, consider
- using {@link #apply} instead.
- @return Returns true if the new values were successfully written
- to persistent storage.*/boolean commit();
commit()- The execution result will be returned .
- If you don't consider the result and execute in the main thread, you can consider
apply().
apply()- Commit your preferences changes back from this Editor to the
- {@link SharedPreferences} object it is editing. This atomically
- performs the requested modifications, replacing whatever is currently
- in the SharedPreferences.
- <p>Note that when two editors are modifying preferences at the same
- time, the last one to call apply wins.
- <p>Unlike {@link #commit}, which writes its preferences out
- to persistent storage synchronously, {@link #apply}
- commits its changes to the in-memory
- {@link SharedPreferences} immediately but starts an
- asynchronous commit to disk and you won't be notified of
- any failures. If another editor on this
Last : Learning summary ——Android Framework architecture knowledge brain map ( Hand painted xmind file )

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211807382360.html
边栏推荐
- mysql8. Cannot start after 0 setting ignores case
- TCP/IP协议
- Akismet plugin tutorial WordPress prevent spam filtering plugin
- Google has been unable to collect the transformation target on the mobile terminal. What's the matter?
- Linux~libc. so. 6 (glibc_2.28) (64bit) is redis-5.0.3-1 nfs. x86_ 64 required
- STM32 MCU memory manager code can be directly used in engineering
- 最基本的JDBC模板及数据库乱码处理
- 靶机渗透练习80-Momentum:1
- Mycat水平分表(E-R表)
- 靶机渗透练习75-DC7
猜你喜欢

靶机渗透练习78-Thoth Tech

不同研发协作模式在云效中的应用

离散数学 命题逻辑

fastjson自动升级成fastjson2后 IDEA开发环境正常 打成jar包发布生成环境后报错异常 pom.xml的version自动升级导致

刚拿的字节跳动offer“打水漂”

靶机渗透练习75-DC7

看看技术宅怎么拯救学霸机,我用10块钱修好了笔记本电脑

【acwing】1118. 分成互质组 ***(DFS)

Finally someone made it clear! It turns out that this is the global one-piece network technology with low delay

最基本的JDBC模板及数据库乱码处理
随机推荐
Educational Codeforces Round 116 (Rated for Div. 2) E. Arena
Porting openharmony and adding WiFi driver
MySQL - remote connection to non local MySQL database server, Error 1130: host 192.168.3.100 is not allowed to connect to this MySQL s
国泰君安安全吗?靠谱嘛
安装网卡驱动失败(已解决)
Mycat水平分表(全局表)
How to get the map value is not so low. There are three ways to get the map parameters
Finally complete the dream of student age - make a handheld machine and teach you with single chip microcomputer STM32
WPF学习笔记——概述
About LINQ statements
Create a local development cluster using k3s
[brush force buckle] questions 51-60
Logstash ~ execution model of logstash
VS2019 visual studio 终端调试乱码问题
Live broadcast with goods source code, different writing methods of gradient status bar
fastjson自动升级成fastjson2后 IDEA开发环境正常 打成jar包发布生成环境后报错异常 pom.xml的version自动升级导致
LogStash~LogStash的多个输入输出
You must understand and can understand microservice series 3: service invocation
信息系统项目管理师专有名词英文缩写&常见词汇
Linux~libc.so.6(GLIBC_2.28)(64bit) 被 redis-5.0.3-1.nfs.x86_64 需要