title: How to interact with db from widget in MVVM pattern
body: <p>I have an application which fetches the data from api and caches in db. I want to be able to show this data (from db) in the widget and also add a button to update the data, which when pressed will fetch the data and update the db and hence update the widget. The problem is since I'm using mvvm, Im not sure if at all it is possible to make use of livedata and fancy supports of jetpack components.</p>
  
  <p>So I just created a Dao reference in widget update fun and fetched the db. That does fetch the data but it is not updating the textview, i logged it and it showed me the data correctly.</p>
  
  <pre><code>companion object {
  
          internal fun updateAppWidget(
              context: Context, appWidgetManager: AppWidgetManager,
              appWidgetId: Int
          ) {
              val db = AppDatabase.getInstance(context.applicationContext).weatherDao()
              val views = RemoteViews(context.packageName, R.layout.weather_widget)
              GlobalScope.launch {
                  val weather = db.getCurrentWeatherMetricAsync()
                  Log.d("TAG_TAG_TAG", "weather: " + weather.temperature);
                  withContext(Dispatchers.Main) {
                      views.setTextViewText(R.id.tv_counter, " asd " + weather.temperature)
                  }
              }
              appWidgetManager.updateAppWidget(appWidgetId, views)
          }
      }
  </code></pre>
  
  <p>the dao has a suspended fun for this.</p>
  
  <pre><code>    @Query("select * from current_weather where id = 0")
      suspend fun getCurrentWeatherMetricAsync(): CurrentMetric
  
  </code></pre>
  
  <p>Can you please tell me how to interact with the db and the proper means to interact with the repository of application?</p>