title: Unable to Insert values in Room Database in Android [Kotlin]
body: <p>I am trying to insert values inside my room database but the App Inspection is showing nothing. I have a complex app structure with lot of tables and one database. I am able to perform CRUD operations on all of the tables except for one. I am not able to identify what I am doing wrong.</p>
  <p>Code --&gt;</p>
  <p><strong>Entity</strong></p>
  <pre><code>@Entity(tableName = &quot;add_time&quot;)
  data class TimeEntity(
  
      @PrimaryKey(autoGenerate = true)
      var id: Int? = null,
  
      @ColumnInfo(name = &quot;start_time&quot;)
      var startTime: String? = &quot;&quot;,
  
      @ColumnInfo(name = &quot;end_time&quot;)
      var endTime: String? = &quot;&quot;,
  
      @ColumnInfo(name = &quot;running_time&quot;)
      var runningTime: String? = &quot;&quot;,
  
      )
  </code></pre>
  <p><strong>DAO</strong></p>
  <pre><code>@Dao
  interface FloorTimeDao {
  
      //Insert time
      @Insert(onConflict = OnConflictStrategy.IGNORE)
      suspend fun insertTimeForScheduling(timeEntity: TimeEntity) {
      }
  }
  </code></pre>
  <p><strong>REPOSITORY</strong></p>
  <pre><code>class AddTimeRepository(private val timeDao: FloorTimeDao) {
  
      //insert
      @WorkerThread
      suspend fun insertTime(time: TimeEntity) = timeDao.insertTimeForScheduling(time)
  }
  </code></pre>
  <p><strong>VIEWMODEL</strong></p>
  <pre><code>class AddTimeViewModel(private val repository: AddTimeRepository) : ViewModel() {
  
      //insert
      fun insertTime(timeEntity: TimeEntity) = viewModelScope.launch {
          repository.insertTime(timeEntity)
      }
  }
  </code></pre>
  <p><strong>VIEWMODEL FACTORY</strong></p>
  <pre><code>@Suppress(&quot;UNCHECKED_CAST&quot;)
  class AddTimeViewModelFactory(private val repository: AddTimeRepository) :
      ViewModelProvider.Factory {
  
      override fun &lt;T : ViewModel&gt; create(modelClass: Class&lt;T&gt;, extras: CreationExtras): T {
          if (modelClass.isAssignableFrom(AddTimeViewModel::class.java)) {
              return AddTimeViewModel(repository) as T
          }
          throw IllegalArgumentException(&quot;Unknown ViewModel Class&quot;)
      }
  }
  </code></pre>
  <p>CODE INSIDE FRAGMENT FOR ADDING VALUE</p>
  <pre><code>        //Inserting new time in the table
          binding.btnAddTime.setOnClickListener {
              try {
                  timeRunning = timeEnd - timeStart
                  timeRunning = abs(timeRunning)
                  Timber.d(&quot;Final Time start : $timeStart&quot;)
                  Timber.d(&quot;Final Time end : $timeEnd&quot;)
                  Timber.d(&quot;Final Time running : $timeRunning&quot;)
                  val timeEntity = TimeEntity(
                      startTime = timeStart.toString(),
                      endTime = timeEnd.toString(),
                      runningTime = timeRunning.toString()
                  )
                  Timber.d(&quot;Time Entity: $timeEntity&quot;)
                  addTimeViewModel.insertTime(timeEntity)
              } catch (e: Exception) {
                  Timber.d(&quot;Exception : $e&quot;)
              }
          }
  </code></pre>
  <p>Everything seems to be added correctly and I still cannot seem to find out what I am doing wrong here. Any help would be appreciated. If you need more code I can provide just let me know.</p>
  <p>NOTE: With this code basically I am trying to store the time in room database which is taken from the user using Time Picker Dialog.</p>
  <p>Edit 1: Found something which I don't know if it is related to the issue or anything. But for the tables in which I am able to insert and read the data the function says something like this :
  <a href="https://i.stack.imgur.com/vBCV7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vBCV7.png" alt="working" /></a></p>
  <p>and for the table (<code>TimeEntity</code>) the function says this :
  <a href="https://i.stack.imgur.com/fc0La.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fc0La.png" alt="not working" /></a></p>
  <p>The difference is that (for the one in which it is working) the functions says <code>Choose Implementation</code> and have a green symbol on left side. But for the table for which it is not working the function says <code>Choose overridden</code> method.</p>
  <p>Update: I was able to fix the issue by creating a new Dao Interface for the table. I am still not very sure what might have been the issue as both DAO files looks same. But I have some doubt that it might be due to the room automatic implementations when we create new DAO's or table.</p>