How can I get current region's code like (i.e. US, UK) selected in Android device.
I don't want to get region/country code from locale because it only returns country code from language selected. Using locale:
String cCode = Locale.getDefault().getCountry();
Whenever user explicitly updates region/country, it must reflect in the app. I need code to get current selected region/country of Android device.

- 4,116
- 5
- 38
- 57
-
What do you mean by "selected in Android device" and "selected region/country of device"? – outis Jan 05 '23 at 22:20
-
Whatever region/country currently selected in android device that I want to get. – Sumit Shukla Jan 06 '23 at 05:32
-
Somewhat similiar question without answer : https://stackoverflow.com/questions/72612020/how-to-get-region-settings-of-android-device-programmatically – Sumit Shukla Jan 06 '23 at 06:28
5 Answers
I was working on the same. This helped me:
Locale current = getResources().getConfiguration().locale;
-
Locale will provide code based on current language but i want it with current region! – Sumit Shukla Jan 05 '23 at 11:48
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 05 '23 at 20:05
you can use the getNetworkCountryIso
method of the TelephonyManager
class to get the country code of the device's current network
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = tm.getNetworkCountryIso();

- 1
- 1
-
No, it will pick country to which user's device is connected . I want to get region selected in the device. – Sumit Shukla Jan 05 '23 at 09:16
-
-
I hope this will work ..
TelephonyManager tm = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String countryCodeValue = tm.getNetworkCountryIso();

- 11
- 6
-
No, it will pick country to which user's device is connected . I want to get region selected in the device. – Sumit Shukla Jan 05 '23 at 09:15
Try this:
String countryCode = Locale.getDefault().getCountry();
String languageCode = Locale.getDefault().getLanguage();

- 2,324
- 26
- 22
- 31

- 204
- 1
- 7
-
Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Jan 05 '23 at 20:10
-
Locale will provide country code based on current language but i want to get country code based on region selected in mobile device. – Sumit Shukla Jan 06 '23 at 13:47
To get the country code, you can use the getCountry() method of the Locale class as shown in the code.
To get the full region/country name, you can use the getDisplayCountry() method of the Locale class as shown in the code above. This will return the full name of the country for the device's current locale in the language of the device.
Locale currentLocale = Locale.getDefault();
String countryCode = currentLocale.getCountry();
String regionName = currentLocale.getDisplayCountry();
For example, if the device's current locale is set to United States, the country code will be "US" and the region name will be "United States". If the device's current locale is set to France, the country code will be "FR" and the region name will be "France". So, this will return both the country name and region name.

- 75
- 7
-
Locale will provide code based on current language but i want it with current region! – Sumit Shukla Jan 05 '23 at 11:48