From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Support deleting all notes

Solution: Support deleting all notes - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Solution: Support deleting all notes

(upbeat music) - For this challenge, I asked you to add code, to allow the user to empty the database. So they could go to the options menu, choose one option and everything would disappear. Here's my solution to this challenge. First in my data access object or DAO interface, I added a new query. I named the function, delete all that could be anything. And I set the return type to end and the SQL statement to delete from notes, because there isn't any where clause that empties the table. Next in my main view model class, I added a new function named delete all notes, and as I've done in the past, I used the view model scope to launch a code routine, and then the width context block to push the code routine into a background threat. Then I called that new delete all function from the DAO to let the user trigger that functionality, I added a new item to my menu and I gave it an idea of action, delete all, and a string of…

Contents