title: Initializing LiveData on ViewModel constructor
body: <p>I am just a beginner in android programming. Recently I am reading about how room database can return live data for automatic updates when changes were made to the database. I am using the viewmodel class instance to hold my Livedata as follows</p>
  
  <pre><code>public class LogVM extends AndroidViewModel{
  
        MasterDatabase roomDatabase;
        LiveData&lt;List&lt;Log&gt;&gt; logData;
  
        LogVM(Application application){
             super(application);
             roomDatabase=MasterDatabase.getInstance(application);
             logData=roomDatabase.getLogDao.getAllLogs();
  
        }
  
         public LiveData&lt;List&lt;Log&gt;&gt; getLogData() {
         return logData;
      }
  
   }
  </code></pre>
  
  <p>The above code actually works fine. But my question is when initializing the logdata in the constructor, aren't we running the database operation on the main thread? But the code compiles and runs without any warning. Can someone explain how?? Sorry if its a silly question. But I am just a beginner!</p>