Skip to content

This library is Android library for using country names and 2-alphabet codes

License

Notifications You must be signed in to change notification settings

takuseno/android-countrylist

Repository files navigation

android-countrylist

This library is Android library for using country names and 2-alphabet codes

##Usage Add repository to your build.gradle

repositories {
    maven { url {'https://raw.github.com/takuseno/android-countrylist/master/repository'}}
}

dependencies {
    compile 'jp.gr.java_conf.androtaku.countrylist:countrylist:1.1.0'
}

In your Java code

//get all countries as objects that contain name and 2-alphabet code
List<Country> countries = CountryList.getCountries(context);

//get all country names as string list
List<String> countryNames = CountryList.getCountryNames(context);

//get all country 2-alphabet code as string list
List<String> countryCodes = CountryList.getCountryCodes(context);

//convert country name into 2-alphabet code
String code = CountryList.convertNameToCode(context, "Japan");
// in this case, code is "JP"

//convert country 2-alphabet code into name
String name = Country.convertCodeToName(context, "JP");
//in this case, name is "Japan"

//get Country object by country name
Country country = CountryList.getCountryByName(context, "Japan");

//get Country object by country 2-alphabet code
Country country = CountryList.getCountryByCode(context, "JP");

Now, English and Japanese country data files are available. If you change name language, you should use following code.

CountryList.dataLanguage = DataLanguage.Japanese;
List<Country> countries = CountryList.getCountries(context);

##Country List If you add other countries, please modify country_code.csv.

And if you add other language data file, you have to check out "CountryList.getFileId".

About

This library is Android library for using country names and 2-alphabet codes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages