Sarthak Salunke
Sarthak Salunke

Reputation: 65

Android app, formatting numbers from contact list

I am retrieving contacts from the device on which the android app is installed. But the numbers I am getting are in the format they are stored on phone. Say, few numbers as '+1-716-XXX-XXXX' ,'(512)XXX-XXXX', '1203XXXXXXX',etc.

I want to use these numbers as a title of table in database. But, if same number is saved in 2 different formats, it is creating 2 different tables. for example, '(716)abc-defg' and '+1-716-abc-defg' is same number, but I am getting different tables for the two

How should I figure out if the table for this number already exist or not? or Is there any way to get them in any one format?

Upvotes: 0

Views: 138

Answers (1)

user3629714
user3629714

Reputation:

Hello you are fetching data from the ContactsContract.CommonDataKinds.Phone.NUMBER row. The row you want is the ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER where all numbers are conveniently formatted for you. I'm in my phone but will update this answer with proper references in a bit.

Edit: there you go! http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Phone.html#NORMALIZED_NUMBER

Upvotes: 1

Related Questions