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 - Android Tutorial
From the course: Building an Android App with Jetpack Libraries
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
-
-
-
-
-
-
-
(Locked)
Add an options menu to the main fragment4m
-
(Locked)
Add sample notes to the database6m 1s
-
(Locked)
Support selecting RecyclerView items7m 12s
-
(Locked)
Delete selected notes from the database4m 28s
-
(Locked)
Challenge: Support deleting all notes1m 57s
-
(Locked)
Solution: Support deleting all notes2m 1s
-
(Locked)
-
-