Introduction to Android Development (20) content provider 20.3 predefined query string constants

Source: Internet
Author: User

In addition to using your own manual write query Uri, you can also use the built-in URI query constants for Android.

For example, in addition to using Content://contacts/people, you can write this assignment statement.

Uri allcontacts = ContactsContract.Contacts.CONTENT_URI;

Some of the built-in predefined query string constants for Android.

Browser.bookmarks_uri

Browser.searchs_uri

Calllog.content_uri

Mediasto Re. Images.Mdeia.INTERNAL_CONTENT_URI

MediaStore.Images.Media.EXTERNAL_CONTENT_URI

S ettings. Content_uri

If you want to query the first contact, you need to specify an ID.

Uri allcontacts = Uri.parse ("CONTENT://CONTACTS/PEOPLE/1");

You can also do this:

Uri allcontacts = Contenturis.withappendedid (ContactsContract.Contacts.CONTENT_URI, 1);

In addition to displaying the contact person in the ListView, you can also print it out.

private void Printcontacts (Cursor c) {  
    if (C.movetofirst ()) {do  
        {  
            String ContactID = c.getstring (c  
                    . Getcolumnindex (contactscontract.contacts._id));  
            String contactdisplayname = C  
                    . getString (c  
                            . Getcolumnindex (ContactsContract.Contacts.DISPLAY_NAME));  
            LOG.V ("Content Providers", ContactID + ","
                    + contactdisplayname);  
        } while (C.movetonext ());  
    }  
}
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.