Initial use of Android Studio, ContentProvider created

Source: Internet
Author: User

Links to tutorial articles for Android Studio

Http://www.open-open.com/lib/view/open1468121363300.html

Content providers can expose their own databases to other users ' applications for access.

* Create a class Provider extend inherit ContentProvider

* Configure content providers in the manifest file. Xml. Configure the full path and host name.

Android:name= "Cn.itcast.contentprovider.PersonDBProvider"

* A URI that defines some data operations in the provider class

Add some specified special paths using the Urimarcher method

Matcher.adduri ("Cn.itcast.contentprovider.personprovider", "Insert", 1); Matcher.adduri (" Cn.itcast.contentprovider.personprovider "," delete ", 2); Matcher.adduri (" Cn.itcast.contentprovider.personprovider "," Update ", 3); Matcher.adduri (" Cn.itcast.contentprovider.personprovider "," Query ", 4);

* To achieve provider additions and deletions of the search method.

***

Querying data by Using content providers

* Get the parser for the content provider

Contentresolver Resolver=getcontentresolver ();

* Use resolver to delete the operation of the check.

NULL NULL NULL null);

while (Cursor.movetonext ()) {
int id = cursor.getint (cursor.getcolumnindex ("id"));
String name = cursor.getstring (Cursor.getcolumnindex ("name"));
String number = cursor.getstring (Cursor.getcolumnindex ("number"));
Person p = new person (ID, name, number);
Persons.add (P);
}
Cursor.close ();

Initial use of Android Studio, ContentProvider created

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.