Is this possible to load a list of all countries in a spinner, then on selecting the particular country, all of its cities appears in another spinner and after selecting the city, we get the list of areas or towns of that city in android using google-api or something like country picker? Currently i am using this to get the list of countries. but how to get their respective cities and towns?
ArrayList<String> list=new ArrayList<String>();
String[] locales = Locale.getISOCountries();
for (String countryCode : locales) {
Locale obj = new Locale("", countryCode);
list.add(obj.getDisplayCountry());
}
There are 195 countries in the world today. This total comprises 193 countries that are member states of the United Nations and 2 countries that are non-member observer states: the Holy See and the State of Palestine.
Our database is: Up-to-date: It was last refreshed in March 2022. Comprehensive: Over 4 million unique cities and towns from every country in the world.
Monaco, Singapore and Vatican City are the only three sovereign states that exist today. Also known as city-states, sovereign states operate independently, housing a whole country in just one city.
Here's a breakdown: Australia has states, but only six. Brazil has 26 states and Mexico 31. India has 28 states and in Europe only one country has states: that's Germany with 16.
You can use the JSON file available here. Just add it to your project into the assets
folder and add the list of cities and countries to spinner after parsing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With