Storage for android _ overview of Storage Methods

Source: Internet
Author: User

As a complete application, data storage operations are essential. Therefore, the Android system provides four data storage methods. They are SharePreference, SQLite, Content Provider, and File. In Android, data is basically private and stored in the "data/package name" directory. Therefore, to share data, use Content Provider.
SQLite: SQLite is a lightweight database that supports basic SQL syntax and is a common data storage method. Android provides a class named SQLiteDatabase for this database, which encapsulates APIs for database operations.

For details, see: SQLite Storage

SharedPreference: in addition to the SQLite database, SharedPreference is another common data storage method. In essence, SharedPreference is an xml file, which is often used to store simple parameter settings.

For details, see SharedPreference storage.

File: A File (I/O) storage method. It is often used to store a large amount of data, but the disadvantage is that updating data will be a difficult task.

ContentProvider: a data storage method that can be shared by all applications in the Android system. Because data is usually private among applications, this storage method is rarely used, however, it is an essential storage method. For example, audio, video, image, and address book can be stored in this way. Each Content Provider provides a public URI (encapsulated as a Uri object). If the application needs to share data, the Content Provider needs to define a URI for the data, then other applications pass in the URI through the Content Provider to operate the data.

PS: URI consists of three parts: "content: //", data path, and ID (optional ).

For details, see ContentProvider storage.

Related Article

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.