1

I'm doing an app in Kotlin where I want to be able to delete things from Realtime Firebase, but before doing that ask the user if he/she/they is sure of that. The idea is having a little window asking that and then having 2 buttons, one that cancels and another that deletes the information from Firebase. Can you help me?

1 Answers1

2

What you need is an AlertDialog or a MaterialAlertDialogBuilder

Have included a simple solution for your reference:

val dialog = AlertDialog.Builder(this)
                    .setIcon(android.R.drawable.ic_delete)
                    .setTitle("Delete")
                    .setMessage("Proceed and Delete")
                    .setPositiveButton("Delete"){ dialog, which ->
                        //Call your Firebase Code/function to delete inside here
                    }.setNegativeButton("Cancel"){dialog, which ->

                       //You don't need this in your case and can skip it
                    }.create()
                    .show()

Cheers,

Tonnie
  • 4,865
  • 3
  • 34
  • 50