0

ネイティブの連絡先のすべての詳細を取得したいのですが、名、姓、携帯電話番号、自宅の番号、勤務先の番号を取得できます。入力されている他の数字は?

Uri contactsUri = ContactsContract.Contacts.CONTENT_URI;
        ContentResolver cr = getContentResolver();
        // Querying the table ContactsContract.Contacts to retrieve all the contacts
        Cursor contactsCursor = getContentResolver().query(contactsUri, null, null, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC ");

        if(contactsCursor != null && contactsCursor.getCount() > 0){
            contactsCursor.moveToFirst();
            do {
                long contactId = contactsCursor.getLong(contactsCursor.getColumnIndex("_ID"));
                Uri dataUri = ContactsContract.Data.CONTENT_URI;

                // Querying the table ContactsContract.Data to retrieve individual items like
                // home phone, mobile phone, work email etc corresponding to each contact 
                Cursor dataCursor = getContentResolver().query(dataUri, null, ContactsContract.Data.CONTACT_ID + "=" + contactId +" AND "+ContactsContract.CommonDataKinds.Phone.TYPE_OTHER +"=7", null, null);


                if(dataCursor != null && dataCursor.getCount() > 0){
                    dataCursor.moveToFirst();
                    // Getting Display Name
                    displayName = dataCursor.getString(dataCursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME ));

                    do{
                        // Getting NickName
                        if(dataCursor.getString(dataCursor.getColumnIndex("mimetype")).equals(ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE))
                            nickName = dataCursor.getString(dataCursor.getColumnIndex("data1"));

                        // Getting Phone numbers
                        if(dataCursor.getString(dataCursor.getColumnIndex("mimetype")).equals(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)){
                            switch(dataCursor.getInt(dataCursor.getColumnIndex("data2"))){
                            case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE : 
                                mobilePhone = dataCursor.getString(dataCursor.getColumnIndex("data1"));
                                break;
                            case ContactsContract.CommonDataKinds.Phone.TYPE_HOME : 
                                homePhone = dataCursor.getString(dataCursor.getColumnIndex("data1"));
                                break;
                            case ContactsContract.CommonDataKinds.Phone.TYPE_WORK : 
                                workPhone = dataCursor.getString(dataCursor.getColumnIndex("data1"));
                                break;  
                            case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER : 


                                otherPhone1 = dataCursor.getString(dataCursor.getColumnIndex("data1"));



                                otherPhone2 = dataCursor.getString(dataCursor.getColumnIndex("data2"));
                                otherPhone3 = dataCursor.getString(dataCursor.getColumnIndex("data3"));
                                otherPhone4= dataCursor.getString(dataCursor.getColumnIndex("data4"));
                                otherPhone5 = dataCursor.getString(dataCursor.getColumnIndex("data5"));
                                Log.d("othertypes of numbersssssssss  ", "other types of numbersssss "+otherPhone1+" "+otherPhone2+" "+otherPhone3);

                                break;  
                            }
                        }
4

1 に答える 1