はあなたのためのコードを働いている
おかげで、:
public static void getContacts(ContentResolver cr) {
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
// read id
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
// read names
String displayName = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
// Phone Numbers
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id }, null);
while (pCur.moveToNext()) {
String number = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
String typeStr = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
}
pCur.close();
...
参考:あなたが投稿したコードからhttp://ganeshtiwaridotcomdotnp.blogspot.com/2011/10/android-code-for-reading-phone-contacts.html
は、我々は変数 'ID' であるかを理解することはできません。あなたはどこで 'id'を定義しましたか、その値は何ですか? – Karthik