1

In my app, I have an sqlite db table that has a "phone number" column.

I get the phone number by querying the devices content providers (sometiemes ContactsContract.PhoneLookup.CONTENT_FILTER_URI and sometimes android.provider.CallLog.Calls.CONTENT_URI) and it seems that in some of the cases I get phone numbers with country code, and sometimes without (it seems inconsistent).

Because of that, when I query my own db, I sometimes do not get results (for example, I stored 99887766 and queried for +199887766).

So, I would like to remove the country code before storing a number in my db table.

I've google it and got to libphonenumber, but I can't figure out how to use it to do what I want (I can't seem to get my devices correct locale (I always get "US") + it seems that this lib makes network transactions; a thing I don't want to do)

So here are my questions:

  1. Is there a way to do what I want (using libphonenumber or in any other way)?
  2. Is there a way to do what I want without making internet transactions.
dors
  • 5,802
  • 8
  • 45
  • 71
  • There is a **[thread][1]** that maybe could help you? [1]: http://stackoverflow.com/questions/12210696/how-to-get-country-or-its-iso-code – Diego Palomar Sep 18 '13 at 08:22
  • Thanks, but the technics in the link you suggested retrieve the device's country code. Say I'm in the US and I get +1, but I want to call my friend in Italy who's number starts with +39. knowing my country code is +1 will not help when processing his phone number – dors Sep 18 '13 at 09:55

0 Answers0