Skip to content

Instantly share code, notes, and snippets.

@WrathChaos
Created November 10, 2015 18:45
Show Gist options
  • Save WrathChaos/ed7c8868177b4dcc75af to your computer and use it in GitHub Desktop.
Save WrathChaos/ed7c8868177b4dcc75af to your computer and use it in GitHub Desktop.
ISO Country List, How to get all country names
//Initializing Country List
final List<Country> countryList=new ArrayList<>();
public void fillCountryList(){
String[] countries = Locale.getISOCountries();
int j = 0;
// Loop each country
for(int i = 0; i < countries.length; i++) {
String country = countries[i];
Locale locale = new Locale("en", country);
// Get the country name by calling getDisplayCountry()
String countryName = locale.getDisplayCountry();
// Printing the country name on the console
countryList.add(new Country(countryName));
j++;
}
Log.d("MyApp", "Total Country # : " + j);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment