title: How to cancel an alertdialog?
body: <p>I wanted to do a password alert box on an activity so once it has the correct answer it closes the dialog box but I cant seem to find a way when searching of how to close a dialog box the way I have coded it anyway.</p>
  
  <p>Here is my code </p>
  
  <pre><code>final AlertDialog.Builder alert1 = new AlertDialog.Builder(this);
  alert1.setTitle("Password");
  alert1.setMessage("Please enter your password below and press Ok.");
  
  final EditText input = new EditText(this);
  alert1.setView(input);
  
  alert1.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {
          String value = input.getText().toString().trim();
          ((Global) Menu.this.getApplication()).setgPassword(value);
          ((Global) Menu.this.getApplication()).setgSiteId(strSavedMem1);
          LogIn();
      }
  });
  
  alert1.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {
          System.exit(0);
      }
  });
  
  alert1.show();
  </code></pre>
  
  <p>Is there a way to close this alertbox?</p>