Simple learning experience: NetEase Cloud Classroom Android Development sixth chapter SQLite and ContentProvider

Source: Internet
Author: User

First, SQLite

1. Basic Operation:

(1) Create a database: Created in the subclass constructor of Sqliteopenhelper.

(2) CREATE TABLE: In the subclass OnCreate method of Sqliteopenhelper, call the Execsql method implementation.

(3) Add, delete, change, check: Call Sqlitedatabase's INSERT, delete, update, query method, or use SQL statements in the Execsql method to achieve the corresponding function.

2. Operate the database with transactions

(1) Start the transaction db.begintransaction () and then perform the operation

(2) The operation is complete then db.settransactionsuccessful ()

(3) Last Db.endtransaction ()

Second, ContentProvider

(1) The role of ContentProvider is to provide application data to other applications.

(2) How to use: First through the Getcontentresolver () method, get the instance object of Contentresolver, and then use the Uri.parse (what data you want to access) to create the URI object, and finally you can use these two objects to operate.

(3) Implementation mode: First create a urilist class to hold the shared URI, and then create the ContentProvider subclass, create Urimatcher in it, add the URI, and then you can implement some of the operations inside the method.

Simple learning experience: NetEase Cloud Classroom Android Development sixth chapter SQLite and ContentProvider

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.