Android Parcelable Parcel HashMap

I want to use Parcelable instead of Serializable in android, because it is faster and recommended. My question is: it seems I can not send LinkedHashMap, a class provided by Java, right?

So for example

public class Person { String name; LinkedHashMap<String,int> age; ... .... } 

How to put this class Person?

Please, help

+1
source share
2 answers

The best I've come up with so far is to use the bundle.

+1
source

Parceler supports LinkedHashMap along with many other standard Java collections. To use Parceler, you just need to annotate your Person class and wrap / expand it in and out of the generated Parcelable :

 Person person = new Person(); Parcels.wrap(person); ... Parcels.unwrap(parcelable); 
0
source

Source: https://habr.com/ru/post/1502218/


All Articles