Created
November 10, 2015 18:45
-
-
Save WrathChaos/ed7c8868177b4dcc75af to your computer and use it in GitHub Desktop.
ISO Country List, How to get all country names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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