Here you can find the source of getAddress(int contactId)
Parameter | Description |
---|---|
contactId | represented contact id |
@SuppressWarnings("deprecation") private static String getAddress(int contactId)
//package com.java2s; import android.app.Activity; import android.database.Cursor; import android.provider.ContactsContract; public class Main { public static Activity mSmartAndroidActivity; /**/*from ww w .j a va2 s.c o m*/ * This method used to get address from contact id. * * @param contactId * represented contact id * @return represented {@link String} */ @SuppressWarnings("deprecation") private static String getAddress(int contactId) { String postalData = ""; String addrWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?"; String[] addrWhereParams = new String[] { String.valueOf(contactId), ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE }; Cursor addrCur = mSmartAndroidActivity.managedQuery( ContactsContract.Data.CONTENT_URI, null, addrWhere, addrWhereParams, null); if (addrCur.moveToFirst()) { postalData = addrCur .getString(addrCur .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS)); } addrCur.close(); return postalData; } }