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 ());
}
}