-1

I have a form in which user has to select his country from a spinner and later user has to select the city from another spinner. So is there anyway to where I can get all the countries in my spinner and the corresponding cities as well? Please help as it will be really impossible to make an array of all the countries and their cities. Thanks

Nikhil
  • 1,212
  • 13
  • 30
user3699550
  • 105
  • 2
  • 12

1 Answers1

9

If you want to get All Contries try as follows

ArrayList<String> list=new ArrayList<String>();

String[] locales = Locale.getISOCountries();

for (String countryCode : locales) {

    Locale obj = new Locale("", countryCode);

    System.out.println("Country Name = " + obj.getDisplayCountry());
    list.add(obj.getDisplayCountry());

}

and set the list to adapter.

As of my knowledge To get cities you have to use webservices.

Hope this will helps you.

Nagaraju V
  • 2,739
  • 1
  • 14
  • 19