title: Android Room LiveData select query parameters
body: <p>I decided to teach myself Java and Android by doing a simple database app. I already implemented some functionality the "lazy" way - all selects are done on the main thread.</p>
  
  <p>Now I want to use LiveData for selects. I've read the <a href="https://developer.android.com/training/data-storage/room/index.html" rel="noreferrer">simplistic training guide on android developers</a> and implemented <a href="https://codelabs.developers.google.com/codelabs/android-room-with-a-view" rel="noreferrer">a more complex solution from codelabs guide</a>, with LiveData and RecyclerView. Inserts, updates, deletes, and selects <em>for whole tables</em> work flawlessly, however I have no idea how to pass parameters to selects.</p>
  
  <p>Example: I have an activity with scrollable list of all records and I want to apply some filters to the list (search). From what I understand the actual select method from DAO is called only once (when ViewModel is created), so <strong>how do I update query with new parameters?</strong></p>
  
  <p>Other example: I have other activity that displays all columns of a record (for viewing and editing). <strong>How do I pass id to query to select a single row?</strong></p>
  
  <p>My database code is more less the same as in <a href="https://codelabs.developers.google.com/codelabs/android-room-with-a-view/#15" rel="noreferrer">this codelab</a></p>
  
  <p><strong>Edit:</strong> I finally did it like that: every time I want to update query parameters I call select from DAO (through ViewModel and Repo) and add a new observer to that new list. This solution doesn't seem optimal but I guess it works...</p>