Four ways to store Android data sharedpreferences, SQLite, Content provider, and file

Source: Internet
Author: User
Tags sqlite database

As a finished 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.

  SQLite: SQLite 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.

  sharedpreference: In addition to the SQLite database, another common method of data storage, which is essentially an XML file, is often used to store simpler parameter settings.

  File : the commonly used method of storing files (I/O), often storing large amounts of data, but the drawback is that updating the data will be a difficult task.

  ContentProvider: A 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.

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

Four ways to store Android data sharedpreferences, SQLite, Content provider, and file

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.