i have developed an application that have one activity and i am going to code on exit pressed,
i want do show dialogue box with three button when user pressed back button one for "yes" second for "home" and third for "exit" and i did it on on-back pressed method but i got some issue its not showing dialogue box if showing then its just flickering of dialogue box so what is reason behind it 

my code is 

```
public class MainActivity extends Activity {

private AlertDialog alertDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

}

@Override
public void onBackPressed() {
    super.onBackPressed();
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            MainActivity.this);

    alertDialogBuilder.setTitle("Alert Dialogue Box");

    alertDialogBuilder.setMessage("Are you sure?");

    alertDialogBuilder.setPositiveButton("Yes",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {

                    Toast.makeText(getApplicationContext(),
                            "Positive", 1000).show();

                }

            });

    alertDialogBuilder.setNegativeButton("No",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                    dialog.cancel();

                    Toast.makeText(getApplicationContext(),
                            "You chose a negative answer",

                            Toast.LENGTH_LONG).show();

                }

            });

    alertDialogBuilder.setNeutralButton("Exit the app",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {

                    Toast.makeText(getApplicationContext(), "exit",
                            1000).show();
                    MainActivity.this.finish();

                }

            });

    AlertDialog alertDialog = alertDialogBuilder.create();

    alertDialog.show();

}

```