How to get Country Code like +91, +1, +65 from the country name like IN, US, SG in Android?

Jayesh picture Jayesh · Dec 16, 2015 · Viewed 8.8k times · Source

I need to get country code like +91, +1, +65... from the country name like IN, US, SG ... using locale or current Location in android device

i.e suppose if device is in India it returns +91, if device is in US it returns +1, if device is in Singapore it returns +65

I have try so many way but I can't get proper solution.

Answer

Ravi picture Ravi · Dec 16, 2015

You can get country ID but not code like +91,+1 and so on

TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
CountryID= manager.getSimCountryIso().toUpperCase();

You can prepare your own database for that and manually you need to search from database and then handle such kind of operations

check here for this kind of data