android - Relationship between sms content provider and contacts -
i have big problem, relationship can between sms content provider , contacts content provider phone numbers sms content provider stores numbers in different format compared how numbers stored in contacts content provider. hence how can compare numbers between 2 tables since dont see other relationship or column binds them. country phone number format +254728306203, how sms provider store number contacts provider stores 072-830-6203 appreciated
try (for sdk 2.0+). let number in format.. pass string...
add permission android.permission.read_contacts
in manifest.
/** * retrieves display name provided contact number * * @param context * context * @param number * contact number display name retrieved * form android contacts * @return returns displayname contact if available. if display name * not available returns same number */ public static string getcontactnamefromnumber(context context, string number) { // if name not found, number returned string contactdisplayname = number; uri uri = uri.withappendedpath(phonelookup.content_filter_uri, uri.encode(number)); cursor cursor = context.getcontentresolver().query(uri, new string[] { phonelookup.display_name }, null, null, null); if (cursor.movetofirst()) { contactdisplayname = cursor.getstring(cursor .getcolumnindex(phonelookup.display_name)); } cursor.close(); log.d("getnumber", "retrived displayname contact number:" + number + " displayname:" + contactdisplayname); return contactdisplayname; }
Comments
Post a Comment