2011-04-06 48 views

回答

1

你需要运行于所有手机查询..

  Cursor phones = cr.query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + " = " + id, null, null); 
      try { 
       phones.moveToFirst(); 
       while (!phones.isAfterLast()) { 
        ContactPhone phone = new ContactPhone(); 
        String number = phones.getString(phones.getColumnIndex(Phone.NUMBER)); 
        // 0 = false | 1 = true 
        int primary = phones.getInt(phones.getColumnIndex(Phone.IS_PRIMARY)); 
        int type = phones.getInt(phones.getColumnIndex(Phone.TYPE)); 
        //Do whatever you want with this info 
        phones.moveToNext(); 
       } 
      } finally { 
       if (phones != null) { 
        phones.close(); 
       } 
      } 
+0

嗨Rafeel如何获得第二个电话号码,这意味着工作电话号码或其他 – Krishna 2011-04-06 23:45:46

+0

运行此查询您正在获取联系人的所有电话。 “type”字段保留Phone类型的值......您可以比较它以获得正确的类型,如下所示: 'if(type == Phone.TYPE_WORK){ //它是一部工作电话 } else if(type == Phone.TYPE_MOBILE){ //手机.. }' – Panthro 2011-04-07 13:57:16

+1

感谢真正有用的感谢简要解释 – Krishna 2011-04-09 00:14:57