title: Android: How to get value from LiveData without Observing it
body: <blockquote>
    <p>Blockquote</p>
  </blockquote>
  
  <p>I have separate classes in which I handle data fetching (Using Room) and I usually return LiveData  list of objects from it and update them. Now I have a settings class where when i press "Backup", i want to have the returned data stored in a ViewModel, but the problem is that in order to get the value, I need to observe the LiveData list of objects. I do not want to observe it since i just need the value (list of objects) to perform the backup. 
  I've tried the below method:</p>
  
  <p>DAO</p>
  
  <pre><code>@Query("SELECT * FROM $DATABASE_TABLE_GOAL")
  suspend fun getAllGoals_NotLive(): List&lt;Goal&gt;
  </code></pre>
  
  <p>ViewModel</p>
  
  <pre><code>var goals_NotLive: List&lt;Goal&gt; = ArrayList()
  
  fun getGoalsNotLive(){
      _uiScope.launch {
  
          withContext(Dispatchers.IO) {
              goals_NotLive = database.goalDao.getAllGoals_NotLive()
          }
      }
  }
  </code></pre>
  
  <p>Activity</p>
  
  <pre><code>fun getGoals(): List&lt;Goal&gt;{
      _viewModel.getGoalsNotLive()
      return _viewModel.goals_NotLive
  }
  </code></pre>
  
  <p>But it stills return Size 0. What should I do?</p>