Alert Dialog shows the Alert message and gives the answer in the form of yes or no. Alert Dialog displays the message to warn you and then according to your response, the next step is processed. Android Alert Dialog is built with the use of three fields: Title, Message area, and Action Button.
Alert Dialog code has three methods: setTitle() method for displaying the Alert Dialog box Title setMessage() method for displaying the message setIcon() method is used to set the icon on the Alert dialog box. Then we add the two Buttons, setPositiveButton and setNegativeButton to our Alert Dialog Box as shown below.