ITEEDU

Andoid2.X查询邮政地址

String addrWhere = ContactsContract.Data.CONTACT_ID +
	" = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
String[] addrWhereParams = new String[]{id,
	ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE};
Cursor addrCur = getContentResolver().query(
	ContactsContract.Data.CONTENT_URI,null, addrWhere, addrWhereParams, null);
while(addrCur.moveToNext()) {
	String poBox = addrCur.getString(
		addrCur.getColumnIndex(
	ContactsContract.CommonDataKinds.StructuredPostal.POBOX));
	String street = addrCur.getString(
		addrCur.getColumnIndex(
	ContactsContract.CommonDataKinds.StructuredPostal.STREET));
	String city = addrCur.getString(
		addrCur.getColumnIndex(
	ContactsContract.CommonDataKinds.StructuredPostal.CITY));
	String region = addrCur.getString(
		addrCur.getColumnIndex(
	ContactsContract.CommonDataKinds.StructuredPostal.REGION));
	String postalCode = addrCur.getString(
		addrCur.getColumnIndex(
	ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE));
	String country = addrCur.getString(
		addrCur.getColumnIndex(
	ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY));
	String type = addrCur.getString(
		addrCur.getColumnIndex(
	ContactsContract.CommonDataKinds.StructuredPostal.TYPE));
}
addrCur.close();