Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use the android sharedpreferences set?
How to use the android sharedpreferences set?
xml data generated by SharedPreferences should be read by using shared preferences, a lightweight memory.

1. SharedPreferences is a lightweight storage class on Android platform, which mainly saves some commonly used configurations, such as window state. Generally, it overloads the window state in Activity and saves it by using SharedPreferences, which provides conventional long-length shaping, Int shaping and String string-type saving on Android platform.

2. SharedPreferences is similar to the ini configuration file on the Windows system in the past, but it is divided into various permissions and can be accessed globally. android123 prompts are finally saved in xml, which is not particularly efficient in overall view. It is much better than SQLite for the conventional lightweight. If the storage capacity is really small, you can consider defining the file format yourself. When xml is processed, Dalvik will parse it through its own local XML Parser, such as XMLpull, which is better for memory resources.

3. Its essence is to store key-value pair data based on XML file, which is usually used to store some simple configuration information. Its storage location is/data/data/<; > /shared_prefs directory.

the p>SharedPreferences object itself can only obtain data, but does not support storage and modification. Storage modification is realized through the Editor object.

4. the steps to realize the storage of SharedPreferences are as follows:

a. obtaining the SharedPreferences object according to the Context

b. obtaining the Editor object by using the edit () method.

c, storing key-value key-value pair data through the Editor object.

d, submit the data through the commit () method.