Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1.  locations = json.getJSONArray(getString(R.string.TAG_LOCATIONS));
  2.  
  3.                     // looping through All Products
  4.                     for (int i = 0; i < locations.length(); i++) {
  5.                         JSONObject c = locations.getJSONObject(i);
  6.  
  7.                         // Storing each json item in variable
  8.                         locationid = c.getString(getString(R.string.TAG_LOCATION_ID));
  9.                         locationname = c.getString(getString(R.string.TAG_LOCATION_NAME));
  10.                         streetaddress = c.getString(getString(R.string.TAG_STREET_ADDRESS));
  11.                         city = c.getString(getString(R.string.TAG_CITY));
  12.                         state = c.getString(getString(R.string.TAG_STATE));
  13.                         zip = c.getString(getString(R.string.TAG_ZIP));
  14.                         latitude = c.getString(getString(R.string.TAG_LATITUDE));
  15.                         longitude = c.getString(getString(R.string.TAG_LONGITUDE));
  16.  
  17.                         // creating new HashMap
  18.                         HashMap<String, String> map = new HashMap<String, String>();
  19.  
  20.                         // adding each child node to HashMap key => value
  21.                         map.put(getString(R.string.TAG_LOCATION_ID), locationid);
  22.                         map.put(getString(R.string.TAG_LOCATION_NAME), locationname);
  23.                         map.put(getString(R.string.TAG_STREET_ADDRESS), streetaddress);
  24.                         map.put(getString(R.string.TAG_CITY), city);
  25.                         map.put(getString(R.string.TAG_STATE), state);
  26.                         map.put(getString(R.string.TAG_ZIP), zip);
  27.                         map.put(getString(R.string.TAG_LATITUDE), latitude);
  28.                         map.put(getString(R.string.TAG_LONGITUDE), longitude);
  29.  
  30.                         // adding HashList to ArrayList
  31.                         locationsList.add(map);
  32.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement