Similarities and differences between the apply and commit methods of Sharedpreference.editor

Source: Internet
Author: User

The difference between the two methods is:
1. Apply does not return a value and a commit returns a Boolean indicating whether the change was committed successfully
2. Apply is to commit the modified data atoms to memory, and then asynchronously commit to the hardware disk, and commit is synchronous commit to the hardware disk, so, in multiple concurrent commit commit, they will wait for the commit to be processed after saving to disk in the operation, thereby reducing the efficiency. while apply is only the atomic commit to the content, the subsequent call to apply the function will directly overwrite the previous memory data, which to a certain extent, improve a lot of efficiency.
3. The Apply method does not prompt for any failed prompts.
Because in a process, sharedpreference is a single instance, there is no concurrency conflict, If you do not care about the results submitted, it is recommended to use apply, of course, you need to ensure that the submission is successful and follow-up, or need to use a commit.

Reference from:

http://blog.csdn.net/jake9602/article/details/18414841

Similarities and differences between the apply and commit methods of Sharedpreference.editor

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.