As a complete application, data storage operations are essential. As a result, the Android system offers four ways to store data. are: Sharepreference, SQLite, Content provider, and file. As the Android system, the data are basically private, are stored in the "data/data/package name" directory, so to achieve data sharing, the correct way is to use the content Provider. SQLiteSQLite is a lightweight database that supports basic SQL syntax and is often used as a way of storing data. Android provides a class named Sqlitedatabase for this database, encapsulating some of the APIs that manipulate the database. sharedpreferenceIn addition to the SQLite database, another common method of data storage, which is essentially an XML file, is often used to store more simple parameter settings. FileCommonly said file (I/O) storage method, often used to store a large number of data, but the disadvantage is that updating data will be a difficult thing. ContentProviderA data storage method that enables all applications to be shared in an Android system, because the data is usually private to each application, so this storage method is less used, but it is an essential storage method. For example, audio, video, pictures, and contacts can generally be stored in this way. Each content provider provides a public URI (wrapped as a URI object), and if the application has data to share, it needs to use content provider to define a URI for the data, and then the other application passes the content Provider pass in the URI to manipulate the data. PS: The URI consists of 3 parts: "content://", the path to the data, and an identity ID (optional). |