Get Country Name String From Country Code Int
I am new in Java Android. I would like to get the name of country (String) using country code in Locale (Ref. ISO 3166-1 numeric) Tried to do something like that (where [...].getCo
Solution 1:
Now an implementation of country code (ISO 3166-1alpha-2/alpha-3/numeric) list as Java enum is available at GitHub under Apache License version 2.0.
Example:
int c_code=profile.getPersonnalInformation().getAddress().getCountry());// 392CountryCodecc= CountryCode.getByCode(c_code);
String country_name=cc.getName(); // "Japan"
Gradle
dependencies {
compile'com.neovisionaries:nv-i18n:1.20'
}
Github
Solution 2:
you have to get the countricode string (2 or 3 letters) to use it. There is a opensource lib on github that will do it for you. see Is there an open source java enum of ISO 3166-1 country codes or take just the enum from https://subversivebytes.wordpress.com/2013/10/07/java-iso-3166-java-enum/
Post a Comment for "Get Country Name String From Country Code Int"