title: Retrieve single record with Room to populate an Edit dialog (activity or fragment)
body: <p>I have a database table which stores some records. I have been able to correctly populate a RecyclerView in a Fragment, following tutorials like <a href="https://codelabs.developers.google.com/codelabs/android-room-with-a-view-kotlin/#0" rel="nofollow noreferrer">this one</a> and similar ones found via search engine.</p>
  
  <p>What I want to do next is to tie an "Edit record {id}" fragment that is tied to the RecyclerView. In other words, if I click on an item in the Recycler view, another fragment(or activity) should open, load the data for record[id] <strong>from the database</strong> and then allow me to save and update the record if needed.</p>
  
  <p>The point where I am stuck is retrieving the single record from the database, because I systematically end up with either (1) calling the query inside the main thread, which Room prevents me from doing, or (2) getting some random null pointer.</p>
  
  <p>I have seen solutions even <a href="https://stackoverflow.com/questions/59859988/obtain-single-user-using-coroutines-with-livedata">here on stackoverflow</a>, but I can't make sense on how to integrate them in my case. </p>
  
  <p>What I can't make sense of is how to make the async call (whether with threads/coroutines), store the result in a variable, and use it to populate the fields in the Edit fragment.</p>
  
  <p>Internet search have been very disappointing, for all I find are (duplicate) tutorials that are either incomplete, irrelevant or obsolete.</p>
  
  <p>Good pointers are welcome. I would prefer <em>not</em> to use third party libraries to do this, unless someone can explain to me the advantages in doing so.</p>
  
  <p>Sorry for the long post: I haven't added code because there would be too many pieces to show and you would probably know anyway. I will answer any questions however to help out.</p>
  
  <p>Also, I am new to Kotlin/Android, and I am trying to tame this beast :-)</p>