title: How to Save the HashMap in Room database without using JSON & GSON?
body: <p>I am trying to store Address in HashMap but the compiler gives the  error: 
  Cannot figure out how to save this field into database. You can consider adding a type converter for it. private java.util.HashMap address;</p>
  
  <pre><code> error: 
      Cannot figure out how to save this field into database. You can consider adding a type converter for it. private java.util.HashMap&lt;java.lang.String, java.lang.String&gt; address;
  </code></pre>
  
  <p>I am using the MapTypeConverter but it doesn't work</p>
  
  <pre><code>object MapTypeConverter {
  
      @TypeConverter
      @JvmStatic
      fun stringToMap(value: JsonElement): Map&lt;String, String&gt; {
          return Gson().fromJson(value,  object : TypeToken&lt;Map&lt;String, String&gt;&gt;() {}.type)
      }
  
      @TypeConverter
      @JvmStatic
      fun mapToString(value: Map&lt;String, String&gt;?): String {
          return if(value == null) "" else Gson().toJson(value)
      }
  }   
  </code></pre>
  
  <p>Room Entity</p>
  
  <pre><code>@Entity
  data class User(
      var ownerName: String? = null,
      var shopNumber: String? = null,
      var deviceToken: String? = null,
      var altNumber: String? = null,
      var address: Map&lt;String, String&gt;? = null
  ) {
      @PrimaryKey(autoGenerate = false)
      var uId: String = "NA"
  }
  </code></pre>
  
  <p>App DataBase</p>
  
  <pre><code>@Database(
      entities = [User::class,ProductDetails::class,CategoryDetails::class],
      version = 1
  )
  @TypeConverters(ConverterListToString::class,MapTypeConverter::class)
  abstract class AppDatabase : RoomDatabase(){
  
      abstract fun getUserDao(): UserDao
      abstract fun getProductDao(): ProductDao
      abstract fun getCategoryDao(): CategoryDao
  
      companion object{
  
          @Volatile
          private var instance: AppDatabase? = null
          private val LOCK = Any()
  
          operator fun invoke(context: Context) = instance ?: synchronized(LOCK){
              instance ?: buildAppDataBase(context).also {
                  instance = it
              }
          }
  
          private fun buildAppDataBase(context: Context) =
              Room.databaseBuilder(
                  context.applicationContext,
                  AppDatabase::class.java,
                   "TradersDatabase.db"
              ).build()
      }
  }
  </code></pre>