I'm designing an android app which must categorise user input based on their location and assign it to the appropriate folder based on the city the user is in. This is trivial when the user is within a large city. The problem arises when the user is in a village or town which will not have its own category in my app. In this case, the user input must be assigned to the nearest large city with 100000 or more residents. I have managed to obtain the user's coordinates so far. I use the following code to obtain the user's city.
List<Address> list = geoCoder.getFromLocation(location
.getLatitude(), location.getLongitude(), 1);
if (list != null & list.size() > 0) {
Address address = list.get(0);
result = address.getLocality();
return result;
This code is not suitable as it returns names of towns and villages as well. What I need to do is to find the nearest city to the given coordinates which has more than 100 000 inhabitants and assign this city to my user input, rather than the village or town in which the user is in. I am looking for suggestions on how this can be done.