Four storage methods for Android data: sharedpreferences, SQLite, content provider, and file (1) -- Overview

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/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, sharedpreference is another common data storage method. In essence, sharedpreference is an XML file, which is often used to store simple parameter settings.

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
The provider will provide a public uri (packaged as a URI object). If the application needs to share data, you need to use the content provider 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 ).

From: http://www.cnblogs.com/wisekingokok/archive/2011/09/13/2174484.html

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.