Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
Updating the Database
You can now modify a crime’s details – but when you navigate away from the detail screen, all your changes are wiped away. Your last task in this chapter will be to save those changes to the database.
To accomplish this task, you will start at the database layer and work your way up.
To begin, open CrimeDao.kt.
Previously, you used the @Query annotation to write functions that query the database.
Other annotations allow you to create functions that add, delete, or update records in the database.
Since the crime you are altering already exists in the database, write a function to update the entry.
Annotate your function with @Update and use the suspend modifier so that you can call it from a coroutine scope. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access