Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- locations = json.getJSONArray(getString(R.string.TAG_LOCATIONS));
- // looping through All Products
- for (int i = 0; i < locations.length(); i++) {
- JSONObject c = locations.getJSONObject(i);
- // Storing each json item in variable
- locationid = c.getString(getString(R.string.TAG_LOCATION_ID));
- locationname = c.getString(getString(R.string.TAG_LOCATION_NAME));
- streetaddress = c.getString(getString(R.string.TAG_STREET_ADDRESS));
- city = c.getString(getString(R.string.TAG_CITY));
- state = c.getString(getString(R.string.TAG_STATE));
- zip = c.getString(getString(R.string.TAG_ZIP));
- latitude = c.getString(getString(R.string.TAG_LATITUDE));
- longitude = c.getString(getString(R.string.TAG_LONGITUDE));
- // creating new HashMap
- HashMap<String, String> map = new HashMap<String, String>();
- // adding each child node to HashMap key => value
- map.put(getString(R.string.TAG_LOCATION_ID), locationid);
- map.put(getString(R.string.TAG_LOCATION_NAME), locationname);
- map.put(getString(R.string.TAG_STREET_ADDRESS), streetaddress);
- map.put(getString(R.string.TAG_CITY), city);
- map.put(getString(R.string.TAG_STATE), state);
- map.put(getString(R.string.TAG_ZIP), zip);
- map.put(getString(R.string.TAG_LATITUDE), latitude);
- map.put(getString(R.string.TAG_LONGITUDE), longitude);
- // adding HashList to ArrayList
- locationsList.add(map);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement