Code example for ContentResolver

Methods: query

0
			Uri contactUri) {
		ContactInfo contactInfo = new ContactInfo();
		long contactId = -1;
 
		// Load the display name for the specified person 
		Cursor cursor = contentResolver.query(contactUri,
				new String[] {
						Contacts._ID, Contacts.DISPLAY_NAME
				}, null, null, null); 
		try { 
			if (cursor.moveToFirst()) {
				contactId = cursor.getLong(0);
				contactInfo.setDisplayName(cursor.getString(1));
			} 
		} finally { 
			cursor.close();
		} 
 
		// Load the phone number (if any). 
		cursor = contentResolver.query(Phone.CONTENT_URI,
				new String[] {
					Phone.NUMBER
				}, 
				Phone.CONTACT_ID + "=" + contactId, null,
				Phone.IS_SUPER_PRIMARY + " DESC");