Delete Country Code From a Contact

Question asked by me:

i would like to know how can i delete or detect the country code of contact

213231756 will be 231756 +231 is the country code of Algeria

+880171876809 will be 0171876009[+88 is the country code of BD]

alert:in contact people can save contact like 231756 [without country code ] this time the contact number remain same

To make myself clear: i create a string.xml file like

<string-array name="CountryCodes" >

And almost 200 country code . and check every contact with the string item which is really time consuming and make my app slow .

Is there any efficient solution to delete the different country code from contact list

Solution by sunil sunny

You can use “libphonenumber.jar” for this.

PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
    // phone must begin with '+'
    PhoneNumber numberProto = phoneUtil.parse(phone, "");
    int countryCode = numberProto.getCountryCode();
} catch (NumberParseException e) {
    System.err.println("NumberParseException was thrown: " + e.toString());

Ovi Majumder

Software Engineer

TopOfStack Software Ltd.