我正在提取地址(城市,国家,街道,电话,电子邮件,网站,组织等)。当我获取所有这些值时,需要很长时间才能获取。
这样做很好,但需要很长时间才能获取。
如何改进?
public void Get_Contact_Address(String id) {
String[] pro = new String[] {
ContactsContract.CommonDataKinds.StructuredPostal.CITY,
ContactsContract.CommonDataKinds.StructuredPostal.TYPE,
ContactsContract.CommonDataKinds.StructuredPostal.STREET,
ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE };
String where = ContactsContract.Data.CONTACT_ID + " = ? AND "
+ ContactsContract.Data.MIMETYPE + " = ?";
String[] whereParams = new String[] {
id,
ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE };
Cursor addrCur = contentresolver.query(
ContactsContract.Data.CONTENT_URI, pro, where, whereParams,
null);
while (addrCur.moveToNext()) {
String type = Null_check(addrCur
.getString(addrCur
.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.TYPE)));
if (type.equals("2")) {
contactcontent.contact_work_address_city = Null_check(addrCur
.getString(addrCur
.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.CITY)));
contactcontent.contact_work_address_postcode = Null_check(addrCur
.getString(addrCur
.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE)));
contactcontent.contact_work_address_street = Null_check(addrCur
.getString(addrCur
.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.STREET)));
break;
}
}
addrCur.close();
}