1

I have a HashMap which I would pass to another Activity class. I simply use this code:

HashMap<String, String> mKeyValues = new HashMap<String, String>();
// add some data to hash map
Intent intent = new Intent(MainActivity.this, SubActivity.class);
intent.putExtra(EXTRA_ENTRIES, mKeyValues);

This is possible because a HashMap already implements the Serializeable interface.

The question is now if this is fast enough for a HashMap with 100 Elements or should I better create a data class which implements the Parcelable interface (because Parcelable is much? faster)?

Is there a guideline when the Parceable interface should be used regarding performance and other things?

I found nothing which compares the duration of passing objects implementing Serializeable and objects implementing Parceable to another Activity.

Regards

sk2212
  • 1,688
  • 4
  • 23
  • 43
  • You could, of course, write a small benchmark that compares Parcelabel and Serializable versions for your 100 element HashMap. Empirical evidence is always the best evidence: You don't need to take any one else's word for it ;-) – David Wasser Sep 11 '12 at 17:17

1 Answers1

0

Using HashMap is just fine and easy, continue with it ;)

ChristopheCVB
  • 7,269
  • 1
  • 29
  • 54