The system provides data processing methods:
1, Sharedpreferences
2. File storage
3, the lightweight data. such as Sqllite
1. Simple Storage
Is the age-old data storage method that Android provides: Sharedperences. Save your data in the simplest way. It shields the underlying file operations and provides a simple program interface for the program staff to save data based on key words.
1.1SharedPreferences
General procedures need to configure parameters such as supporting data, under Windows is almost and EXE in a directory. When the program starts, it reads the parameter file, which changes the contents of the program. The Android app's parameter file is implemented via Sharedpreferences.
The format is: INI and XML, or a file of your own custom format.
Sharedpreferences provides a way to handle these three ways.
1.2 Access to three modes:
Mode_private; (Read and write only)
Mode_world_readable (Other people can read)
Mode_world_writeable (Other people can write)
Define access mode before access: public Staticint mode=mode_private;
Read/write mode mode=context.mode_world_readable+context.mode_world_writeable;
1.3 How to obtain an instance:
public static final String preference_name= "SaveSetting";
Sharedperferences sharedpreferences=getsharedpreferences (Preference,mode);
Sharedpreferences can be modified by class after 1.4
String name = sharedprefences.getstring ("name", John Doe ");
int age = Sharedprefences.getint ("Age", 21);
float height = sharedprefences.getfloat ("height", 1.80f);
Sharedpreferences.editor Editor = Sharedpreferences.edit ();
Editor.putstring ("Name", "usegear");
Editor.putint ("Age", 101);
Editor.putfloat ("Height", 1.81f);
Editor.commit ();
Call commit () to save the underlying data type, including Integer, Boolean, float, long, and so on.
Android Data and Access (1)-Where do I put my app configuration parameters file?