title: onClick close the application
body: <p>i have an android application .. i want whrn the user clicks on exit button it will displays a confirmation message and if he clicked yes the close the whole application ..</p>
  
  <p>tried this code but didn't work:</p>
  
  <pre><code>AlertDialog.Builder alertBuilder=new AlertDialog.Builder(AdminEditProfile.this);
  alertBuilder.setTitle("Exit");
  alertBuilder.setMessage("Are you sure you want to exit from the application?");
  alertBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
  
      public void onClick(DialogInterface dialog, int which) {
  
          dialog.cancel();
          android.os.Process.killProcess(android.os.Process.myPid());
          System.exit(1);
      }
  });
  alertBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
  
      public void onClick(DialogInterface dialog, int which) {
  
          dialog.cancel();    
      }
  });
  alertBuilder.create().show();
  </code></pre>
  
  <p>is there a way to do it ></p>
  
  <p>please help, thank you :).</p>