ContentProvider抓取通讯录数据

旧版本的写法:
import android.provider.Contacts;

Cursor c = getContentResolver().query(Contacts.Phones.CONTENT_URI, null, null,
				null, null);
		startManagingCursor(c);
		ListAdapter adapter = new SimpleCursorAdapter(this,
				android.R.layout.simple_list_item_2, c, new String[] {
						Contacts.Phones.DISPLAY_NAME, Contacts.Phones.NUMBER_KEY },
				new int[] { android.R.id.text1, android.R.id.text2 });
		setListAdapter(adapter);


新版本写法:
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.CommonDataKinds.Phone;

Cursor c = getContentResolver().query(
	Data.CONTENT_URI,
	new String[] { Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL,
						Phone.DISPLAY_NAME }, null, null, null);
startManagingCursor(c);
ListAdapter adapter = new SimpleCursorAdapter(this,
	android.R.layout.simple_list_item_2, c, new String[] {
	Phone.DISPLAY_NAME, Phone.DATA1}, new int[] {
	android.R.id.text1, android.R.id.text2 });
setListAdapter(adapter);

你可能感兴趣的:(C++,c,android,C#)