在使用Lint检查代码时,得到提示
Consider using apply() instead; commit writes its data to persistent storage immediately, whereas apply will handle it in the background
通过阅读文档得知只要区别在于:
- commit() API Level 1。apply() API Level 9。
- commit()有boolean返回值,确认是否写入数据成功。applay()无返回值。
- commit()立刻写入存储器中,apply立刻提交到内存中并在子线程中写入存储器。


发布评论