Android contentprovider Data Sharing Method

Source: Internet
Author: User

Android provides contentprovider. A program can completely expose its data by implementing an abstract interface of contentprovider, and contentproviders exposes data in a way similar to a table in a database, that is to say, contentprovider is like a "Database ". The data provided by the outside world should be basically the same as the data obtained from the database, except that the URI is used to indicate the "Database" that the outside world needs to access ". As for how to identify which database is needed from the URI, this is what the android underlying layer needs to do. In brief, contentprovider provides external data operation interfaces:

Query (Uri, string [], String, string [], string)

Insert (Uri, contentvalues)

Update (Uri, contentvalues, String, string [])

Delete (Uri, String, string [])

 

These operations are basically the same as database operations. For details about the parsing, refer to the detailed description in Android SQLite parsing. Uri:

The D part of URI may contain a _ id, which should appear in the SQL statement and can appear in a special way. This requires that when we provide data, you need to pay attention to this special information. The recommended method for Android SDK is to include an ID in the provided data table field. During table creation, integer primary key autoincrement identifies this ID field.

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.