I'd need to get the full country name from the country code.
For example for Netherlands, I'd need the Netherlands
from the country code NL
.
I thought I could do that with Locale
like:
Locale loc = new Locale("NL");
loc.getCountry();
but loc.getCountry();
is empty.
Any idea about how to do this, please?
Thanks in advance!
try like this
Locale loc = new Locale("","NL");
loc.getDisplayCountry();
Hope this will help out.
This should work:
Locale l = new Locale("", "NL");
String country = l.getDisplayCountry();
The first parameter of Locale is the language, which is not useful in your case.
Try to use the other constructor
Locale loc = new Locale("NL", "The Netherlands");
Locale
There does not appear to be a predefined Locale for The Netherlands
for a full solution TelephonyManager (from this solution):
TelephonyManager teleMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String localeCountry = teleMgr.getNetworkCountryIso();
if (localeCountry != null) {
Locale loc = new Locale("",localeCountry);
Log.d(TAG, "User is from " + loc);
}