I just configured some data in an ArrayList of HashMaps, which will be sent to another activity. There it will get decoded and the values are then stored in particular arrays. Let me show my code which I configured in the 1st Activity:
ArrayList<HashMap<String, String>> hashMapArrayList = new ArrayList<HashMap<String, String>>();
JSONArray jsonArray = new JSONArray(cena);
for(int i=0; i<jsonArray.length(); i++) {
//ointer exception
jsonObject = jsonArray.getJSONObject(i);
pr = jsonObject.getString("price");
cgN = jsonObject.getString("categoryName");
pN = jsonObject.getString("productName");
cN = jsonObject.getString("catalogName");
HashMap<String, String> hashMap = new HashMap<String, String>();
hashMap.put("Price", pr);
hashMap.put("CategoryName", cgN);
hashMap.put("ProductName", pN);
hashMap.put("CatalogName", cN);
hashMapArrayList.add(hashMap);
Intent intent = new Intent(Login.this, Checkout.class);
//I took bundle but type convention error was coming
intent.putExtra("arrayhash", hashMapArrayList);
startActivity(intent);
}
Now in 2nd Activity,
ArrayList<HashMap<String, String>> hashMapArrayList2 =
(ArrayList<HashMap<String, String>>) getIntent().getSerializableExtra("arrayhash");
// Now here I am confused with extracting and also after extracting storing it like this:
/*String price[];
String categoryName[];
String productName[];
String catalogName[];*/
A big thanks, deeply appreciated.