views:

52

answers:

1

can someone help me with the following code to get the address stored from the contact??

THANK YOU!

// Extract the address. String where = ContactsContract.ContactMethods.PERSON_ID + " == " + id + " AND " + ContactsContract.ContactMethods.KIND + " == " + ContactsContract.KIND_POSTAL;

  addressCursor = context.getContentResolver().query(ContactsContract.ContactMethods.CONTENT_URI, null, where, null, null);

  // Extract the postal address from the cursor
  int postalAddress = addressCursor.getColumnIndexOrThrow(ContactsContract.ContactMethodsColumns.DATA);

  String address = "";
  if (addressCursor.moveToFirst())
    address = addressCursor.getString(postalAddress);
  addressCursor.close();
A: 

have you checked with manifest file permissions??

the100rabh
yea i'd checked the manifest file...i had error at for all the ContactsContracts class
KKC
Your comment is not very clear, what the issue that u had ??
the100rabh
Im having problems on this chunk of code..the Contacts.ContactsMethod was deprecated..is there other class that i can use? String where = ContactsContract.ContactMethods.PERSON_ID + " == " + id + " AND " + ContactsContract.ContactMethods.KIND + " == " + ContactsContract.KIND_POSTAL; addressCursor = context.getContentResolver().query(ContactsContract.ContactMethods.CONTENT_URI, null, where, null, null); int postalAddress = addressCursor.getColumnIndexOrThrow(ContactsContract.ContactsColumns.DATA);
KKC