1
votes

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

1
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

1 Answers

0
votes

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