title: Android Room : LiveData callback of update insert?
body: <p>I have a <a href="https://github.com/charlesng/SampleAppArch/tree/master/feedentry/src/main/java/com/example/feedentry/datasources/room" rel="noreferrer">Simple DAO</a> including CRUD function</p>
  
  <p>FeedEntryDAO.java </p>
  
  <pre><code>@Dao
  public interface FeedEntryDAO {
  
    @Query("SELECT * FROM feedEntrys")
    LiveData&lt;List&lt;FeedEntry&gt;&gt; getAll();
  
    @Query("SELECT * FROM feedEntrys WHERE uid = :uid LIMIT 1")
    LiveData&lt;FeedEntry&gt; findByUid(int uid);
  
    @Insert
    void insertAll(FeedEntry... feedEntries);
  
    @Delete
    void delete(FeedEntry feedEntry);
  
    @Update
    int update(FeedEntry feedEntry);
  
  }
  </code></pre>
  
  <p>For the <code>select</code> , it is okay to return the LiveData type.</p>
  
  <p>Inside the Activity the code is pretty for the selection </p>
  
  <pre><code>viewModel.getFeedEntrys().observe(this,entries -&gt; {...});
  </code></pre>
  
  <p>However, when I try to insert, update , delete the data. The code seems a little bit ugly and also create a asynctask every time. </p>
  
  <pre><code>new AsyncTask&lt;FeedEntry, Void, Void&gt;() {
                  @Override
                  protected Void doInBackground(FeedEntry... feedEntries) {
                    viewModel.update(feedEntries[0]);
                    return null;
                  }
  }.execute(feedEntry);
  </code></pre>
  
  <p>I have 2 question about it:</p>
  
  <ol>
  <li>Can I use LiveData to wrap the delete, insert , update function ?</li>
  <li>Better way to maintain such asynctask class for delete, insert , update?</li>
  </ol>
  
  <p>Appreciate any suggestions and advices. Thank you.</p>