Search code examples
androidlocale

Get country name in English from country code


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.

How can I do this?


Solution

  • Java

    Locale loc = new Locale("","NL");
    loc.getDisplayCountry();
    

    Kotlin

    import java.util.Locale
    Locale("", "NL").displayCountry