From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

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

Delete selected notes from the database

Delete selected notes from the database - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Delete selected notes from the database

- [Narrator] Now that I have the logic in place to select notes, I need to act on those selections and I'm going to do that by deleting them in bulk. When the user clicks or taps the trash can icon, I'll just react by deleting the selected notes. There are a few steps to go through. First, I'll start in my main fragment and I'll add a bit of code here to handle this selection of that trash can icon. I'll look for R.id.action_delete. And when that's selected, I'll call a new function that I need to create that I'll name deleteselectedNotes. Now that function doesn't exist. So I need to create it. And first I need to return a value of true. And I have to do that because I'm returning this from within a when clause and from here I'll call view model. And once again, I'll be calling a function that doesn't exist yet. It'll be called deleteNotes, and I'm going to pass in my array list of notes. And I'll get that…

Contents