Android data storage methods and android Storage

Source: Internet
Author: User

Android data storage methods and android Storage

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.

SharedPreference

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

File

That is to say, the file (I/O) storage method is often used to store a large amount of data, but the disadvantage is that updating data will be difficult.

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 ).

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.