How can I get the country (or its ISO code)?

Vishal Pawar picture Vishal Pawar · Aug 31, 2012 · Viewed 73.7k times · Source

What is the best way to get the country code?

As of now, I know two ways. One is to get by TelephonyManager and another by Locale. Which is another best and unique way to find the country code on Android?

Answer

Sahil Mahajan Mj picture Sahil Mahajan Mj · Sep 6, 2012

Try this:

TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = tm.getSimCountryIso();