Go Android sharedpreferences Use

Source: Internet
Author: User

1, Sharedperferences Save the data is mainly similar to the configuration information Format data, so it is mainly stored data is a simple type of key-value, sharedpreferences itself does not have the ability to write data, Instead of Sharedpreferences's internal interface, Sharedpreferences calls the edit () method to get the editor object that he corresponds to, and editor provides many ways to manipulate the data:

(1), Sharedpreferences.editor Clear (): empty all the data inside the sharedpreferences;

(2) SharedPreferences.Editor.putXX: A value corresponding to the specified key is deposited into the sharedpreferences, where xx is the basic type of data deposited;

(3) SharedPreferences.Editor.remove (String key): Delete the item that corresponds to the key specified in the sharedpreferences;

(5) Boolean commit () The method is called when editor is completed to commit the modification.

2. Sharedpreferences. itself is an interface, the program cannot directly create Sharedpreferences. instance, only the get sharedpreferences provided by the context. (String name, int Mode) method to obtain sharedpreferences. Instances where the mode can be obtained with the following values:

Context.mode_private: The specified sharedpreferences data can only be read and written by the program itself;

Context.mode_world_private: Specifies that the sharedpreferences data can be read by other programs but cannot be written;

Context.mode_world_writeable: Specifies that the sharedpreferences data can be read and written by other applications

Original address:

http://blog.csdn.net/liu1028701143/article/details/7085088

Go Android sharedpreferences Use

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.