title: kotlin, how to put HashMap in Parcelable
body: <p>In a class who implements Parcelable it has a HashMap member.</p>
  
  <p>Saw Parcelable has 
  <code>public final void readMap(Map outVal, ClassLoader loader)</code>,  but could not find a sample to use it.</p>
  
  <p>If do it by flatten the map and write/read one by one accordingly, how to extract from the parcel in the constructor? (got error to build the map from the parcelable,  <code>cannot access buildTheMap() before constructor is called</code>)</p>
  
  <pre><code>class CachedData(val type: Int,
               val name: String,
               val details: HashMap&lt;String, String) :
      Parcelable {
  
  constructor(parcel: Parcel) : this(
          parcel.readInt(),
          parcel.readString(),
  
          // how to get the hashMap out of the parcel???
          buildTheMap(parcel)   //&lt;=== cannot access buildTheMap() before constructor is called
  )
  
  fun buildTheMap(parcel: Parcel) :HashMap&lt;String, String&gt; {
  
      val size = parcel.readInt()
      val map = HashMap&lt;String, String&gt;()
  
      for (i in 1..size) {
          val key = parcel.readString()
          val value = parcel.readString()
          map[key] = value
      }
      return map
  }
  
  override fun writeToParcel(parcel: Parcel, flags: Int) {
      parcel.writeInt(type)
      parcel.writeString(name)
  
      // how to write the HashMap&lt;String, String&gt; to the parcel
      //parcel.???
  
      parcel.writeInt(details.size)
      for ((key, value) in details) {
          parcel.writeString(key)
          parcel.writeString(value)
      }
  }
  
  override fun describeContents(): Int {
      return 0
  }
  
  companion object {
      @JvmField val CREATOR: Parcelable.Creator&lt;CachedData&gt; = object : Parcelable.Creator&lt;CachedData&gt;{
          override fun createFromParcel(parcel: Parcel): CachedData {
              return CachedData(parcel)
          }
  
          override fun newArray(size: Int): Array&lt;CachedData?&gt; {
              return arrayOfNulls(size)
          }
      }
  }
  </code></pre>
  
  <p>}</p>