I have a JSON that contains the names of Countries, their states and cities of those states. Here is the [json](https://github.com/sagarshirbhate/Country-State-City-Database/blob/master/Contries.json). 

I am able to get all the countries but I can't figure out how to get the states based on the selected country and then cities based on the selected state.

Here is how I got the countries.`enter code here`

First to load the file from assets:

```
public String loadJSONFromAsset() {
    String json = null;
    try {
        InputStream is = getAssets().open("Contries.json");
        int size = is.available();
        byte[] buffer = new byte[size];
        is.read(buffer);
        is.close();
        json = new String(buffer, "UTF-8");
    } catch (IOException ex) {
        ex.printStackTrace();
        return null;
    }
    return json;
}

```

Then to load the countries into an ArrayList.

```
public void loadCountries(String parent, String child, ArrayList<String> listValue)
{
    try {

        JSONObject obj = new JSONObject(loadJSONFromAsset());
        JSONArray m_jArry = obj.getJSONArray(parent);;
        ArrayList<HashMap<String, String>> formList = new ArrayList<HashMap<String, String>>();

        HashMap<String, String> m_li;

      //  listValue = new ArrayList<>();

        for (int i = 0; i < m_jArry.length(); i++) {
            JSONObject jo_inside = m_jArry.getJSONObject(i);

            listValue.add(jo_inside.getString(child));
        }

    } catch (JSONException e) {

        e.printStackTrace();
    }

}

```

Then this line finally:

```
loadCountries("Countries", "CountryName", countries);

```

After I have selected a country, I want to load its states. maybe something like this:

```
loadCountries("Pakistan", "StateName", states);

```

and then:

```
loadCountries("Islamabad Capital Territory", "CityName", cities);

```

Any help is greatly appreciated.