1

I had to create a "multimap" type data structure for my android app that looks like this

HashMap<Integer, String []> sampleStorage = new HashMap<Integer, String []>

I am trying to pass it through several activities but it fails to pass to the first activity. I know this because the data is available in the activity that it is created but not available in the activity I pass the intent to.

I am using this code to add it to the intent and send it

Intent intent = new Intent(this, MyActivity.class);

Bundle args = new Bundle();
args.putSerializable("sampleStorage", (Serializable)sampleStorage);
intent.putExtra("BUNDLE", args);

And this is the code I am using to retrieve it

Intent intent = getIntent();
Bundle args = intent.getBundleExtra("BUNDLE");

sampleStorage = (HashMap<Integer, String []>) args.getSerializable("sampleStorage");

The error that gets thrown when I try to access it in the second activity is a NullPointerError so it seems like it doesn't even make it to the second activity. Any help will be greatly appreciated, thank you in advance.

Zach M
  • 11
  • 1

1 Answers1

0

So after a few days of scouring my code I found out that there was a secondary declaration of sampleStorage that was overwriting my initial hash map. Sorry that I originally didn't provide enough of my code for someone to properly answer the question in the first place.

Zach M
  • 11
  • 1