The code what you have written is fine.But this lines leads to Exception
..
super.onBackPressed();
which is finish your Activity
so your Dialog
is dismissed with Window leak Exception.
So remove that line from your code.
Add this line to cancel touch on Outside.
alertDialog.setCanceledOnTouchOutside(false);