【Android】SharedPreferences commit(同步)apply(异步)

Unlike commit(), which writes its preferences out to persistent storage synchronously, apply() commits its changes to the in-memory SharedPreferencesimmediately but starts an asynchronous commit to disk and you won’t be notified of any failures. If another editor on this SharedPreferences does a regularcommit() while a apply() is still outstanding, the commit() will block until all async commits are completed as well as the commit itself.

    原文作者:tuhuolong
    原文地址: https://blog.csdn.net/tuhuolong/article/details/20644501
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞