The problem i've stuck is
I have 4 activities namely A, B ,C and D . the flow is first A then B then C and so on.
I want to pass data of A to B and then data A+B to C , then data of A+B+C to D and so on..
I've used in Activity A Intent of Hashmap
HashMap<String, String> hashMap = new HashMap<>(); //declared Globally
hashMap.put("key", value);
i.putExtra("map", hashMap); (i is the Intent Object)
startActivity(i); //Starting the Intent
And on receiving side i.e Activity B
HashMap<String, String> hashMap = (HashMap<String, String>)i.getSerializableExtra("map");
Here i'm able to get Successfully the data , but when i try to pass on foward this data to next activity i get null values causing NullPointerException
.
In the B activity
Hashmap<String,String> hashMap2 = new HashMap<>;
hashMap2.put("key",hashMap.get("key"));
Log.i("Value:",hashMap.get("key"));
Here i get the values successfully put when same way i pass hashmap2
to C activity i get NullPointerException
.
Not understanding what's wrong in here.
I want to pass the values and not store them so i'm preferring Intents over Shared Preferences.
Thanks for your help .I've found out why it was giving me null values 1)In B activity I was doing the wrong way to get the values i.e first getIntent and then sum of A+B values i.e putExtra should be used only when I declare the new intent for the C class. As i was first doing putExtra and then new Intent to C , so in C i used to get Null Values.