0

I am currently exporting some of the phone numbers of contacts stored in the Contacts content provider, and I would like to know if something exists to get the 'formated' string for the phone number e.g. instead of xxx-xxx-xxxx => xxxxxxxxxx. for a better DB consistency.

It would be pretty easy with a reg-ex, but i'd like to know if something already exists for this purpose, as the doc. mentions :

public static final String NUMBER - Since: API Level 5
The phone number as the user **entered it**.
Type: TEXT - Constant Value: "number"

which let's me think a standard format exists somewhere ... ? Thanks in advance !

olamotte
  • 917
  • 9
  • 20

3 Answers3

0

As far as I know something like this doesn't exist. I think you will have to write your own.

Camille Sévigny
  • 5,104
  • 4
  • 38
  • 61
0

Reg-ex it! Pretty sure nothing like this exists.

Martyn
  • 16,432
  • 24
  • 71
  • 104
0

If you Don't want to use Reg-ex code than use below code for get this type of formatted number

String[] temp=SelectedContactNo.split("-");
        String MoNo="";
        int len=temp.length;
        for(int j=0;j<len;j++)
        {
            MoNo +=temp[j];
        }

Now you'll use MoNo as formatted String.

Girish Bhutiya
  • 3,111
  • 5
  • 31
  • 50