Tôi muốn tìm nạp loại nhãn email type
và phone number type's
được sử dụng nhưng khi tìm nạp dữ liệu bằng cách sử dụng mã này, vị trí sử dụng nhãn của nó có nghĩa là trả về giá trị integer
. nhãn được sử dụng.nhận được loại email và loại số điện thoại của nhãn được sử dụng android
Trường hợp tôi sai trong mã của tôi?
Nhận đầy đủ id email thành công nhưng đối với loại tặng int
. giá trị là 1,2.
Vậy làm cách nào để nhận nhãn cho loại?
public String [] getEmailid(long _id) {
String emailid = null ;
String emailType = null ;
try {
Cursor cursor = getContentResolver().query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
new String[]{Email.DATA,Email.TYPE},
ContactsContract.CommonDataKinds.Email.CONTACT_ID +" = "+ _id,
// We need to add more selection for phone type
null,
null);
if(cursor != null) {
while (cursor.moveToNext()) {
// This would allow you get several email addresses
// if the email addresses were stored in an array
// Log.i("RETURN EMAIL TYPA",emailid);
emailid = cursor.getString(cursor.getColumnIndex(Email.DATA));
emailType = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
// TODO Auto-generated method stub
if(emailid != null)
break;
}
}
}
//.....
Vui lòng thêm một số giải thích lý do tại sao và làm thế nào điều này giải quyết câu hỏi của OP. –