content: package com.example.kesara.alert;
  
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  public class MainActivity extends AppCompatActivity {
  
      private Button btn;
      private Button btn2;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          btn = findViewById(R.id.button);
          btn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
                  alertDialog.setCancelable(false);
                  alertDialog.setTitle("Alert");
                  alertDialog.setMessage("Alert message you can see here");
                  alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK",
                          new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int which) {
                                  dialog.dismiss();
                              }
                          });
                  alertDialog.show();
              }
          });
  
          btn2 = findViewById(R.id.button2);
          btn2.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
                  alertDialog.setCancelable(false);
                  alertDialog.setTitle("Delete");
                  alertDialog.setMessage("Are you sure you want to delete?");
                  alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "DELETE",
                          new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int which) {
                                  AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
                                  alertDialog.setCancelable(false);
                                  alertDialog.setMessage("Successfully Deleted");
                                  alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK",
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog, int which) {
                                                  dialog.dismiss();
                                              }
                                          });
                                  alertDialog.show();
                              }
                          });
                  alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel",
                          new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                  dialog.cancel();
                              }
                          });
                  alertDialog.show();
              }
          });
  
      }
  }
  