Sharedpreference is a lightweight storage class on the Android platform that holds some of the most commonly used configurations of the app, such as activity status, Activtiy pauses, and saves the activity's state to Sharedpreferences , when the activity is overloaded, the system callback method Onsavedinstancestate, and then takes the value out of the sharedpreferences, and finally saves it in. xml, which is not very efficient.
4 Modes of data operation:
1.context. Mode_private: The default is private data that is accessed only by the application itself, and the content written in that mode overwrites the contents of the original file.
2.context. Mode_append: This mode checks whether a file exists, appends content to it, and creates a file that does not exist.
3.context. Mode_word_readable: Indicates that the current file can be read by another file.
4.context. Modee_word_writeable: Indicates that the current file can be written by another application.
Activity can share data directly through Sharedpreferences.
sharedpreference function and Data operation mode