0

As far I know, in android devices, we can fetch the country code by getting the property ro.product.region till version 5.X and ro.product.locale in later versions. But in some devices (ex: Lenovo tab4 8), there is no ro.product.region or ro.product.locale. Instead there is a property ro.lenovo.country and it gives the country code. Is there any standard way to get the country code of the device other than reading the above ro.product.region/locale properties? I need this to be working across all the devices irrespective of manufacturer.

Pendyala
  • 585
  • 1
  • 6
  • 17

2 Answers2

0

If there is sim inside android phone you can use below to get country code .

TelephonyManager tm =  (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String countryCodeValue = tm.getNetworkCountryIso();

Check how can i get my android device country code without using GPS? for more clarification.

SimpleCoder
  • 1,665
  • 1
  • 21
  • 34
  • TelephonyManager documentation says "Returns the ISO country code equivalent of the MCC (Mobile Country Code) of the current registered operator, or nearby cell information if not registered". So basically it is giving the country value based on the location the device is in. But I want to know the country for which device is made for. – Pendyala Aug 09 '18 at 06:09
  • And also the above mentioned code will not work for tabs. – Pendyala Aug 09 '18 at 06:29
0

try this one

TelephonyManager manager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String DEVICE_COUNTRY = manager.getSimCountryIso();

work for me

Aanal Shah
  • 273
  • 1
  • 2
  • 14