title: Unable to fetch data from Room database using view model
body: <p>I am using room db in my app and I am using MVVM design pattern.When I am creating view model in that at the time of accessing dao method its showing me below error.</p>
  <pre><code>No value passed for parameter 'context'
  </code></pre>
  <p>Below is my code:</p>
  <p><strong>RoomDb.kt</strong></p>
  <pre><code>@Database(entities=[UserEntity::class],version = 1)
  abstract class RoomDb: RoomDatabase() {
  
  abstract fun useDao():UserDao
  
  companion object{
  
      private var INSTANCE:RoomDb ?= null
  
      fun getRooomDb(context: Context): RoomDb{
  
          if(INSTANCE == null){
  
            INSTANCE = Room.databaseBuilder&lt;RoomDb&gt;(
                context.applicationContext,RoomDb::class.java,&quot;AppDb&quot;
            ).allowMainThreadQueries().build()
          }
  
          return INSTANCE!!
       }
     }
  }
  </code></pre>
  <p><strong>UserDao</strong></p>
  <pre><code>@Dao
  interface UserDao {
  
  @Query(&quot;SELECT * FROM Users ORDER BY id DESC&quot;)
  fun getAllUsers(): List&lt;UserEntity&gt;
  
  @Insert
  fun insertUser(user: UserEntity)
  
  @Delete
  fun deleteUser(user: UserEntity)
  
  }
  </code></pre>
  <p><strong>HomeViewModel.kt</strong></p>
  <pre><code>class HomeViewModel: ViewModel(){
  
  fun allUser(){
  
      val db = RoomDb.getRooomDb().useDao()
    }
  }
  </code></pre>
  <p>I am getting error in <code>RoomDb.getRooomDb().useDao()</code> line.Someone let me know how can I resolve this error.</p>