Problem with AlertDialog.Builder

Hi,
I’ve a problem with AlertDialog.Builder. I’m a french begginer in java net/android. I’ve a button suppress and in this, i’ve had an AlertDialog.Builder to confirm the suppress.
The alert is displayed on the simulator, but there is no action when i click on a button, and this alert is displayed a very short time and quickly disappear.
Have you an idea
Thank you very much for your help

Best tegards
PS I join a picture of the display of the simulator


here’s my code:

ImageButton BoutonSupprimer = findViewById(R.id.buttonSupprimer);
BoutonSupprimer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDatabase = FirebaseDatabase.getInstance().getReference();
if (WSAutUser.equals(“AMI”)) {
if (WsUser.equals(ZUser)) {

                AlertDialog.Builder dialog = new AlertDialog.Builder(ListeAnnoncesActivity.this)
                        .setIcon(R.drawable.alerte)
                        .setTitle("Suppresion annonce")
                        .setMessage("Etes vous sûr de supprimer cette annonce")

                        .setPositiveButton("Oui", new DialogInterface.OnClickListener() {
                            @TargetApi(11)
                            public void onClick(DialogInterface dialogInterface, int which) {
                                mDatabase.child(WsCleAEF).removeValue();
                                Iterator itr = ContenuAnnonce.iterator();
                                while (itr.hasNext()) {
                                    if (itr.next().equals(WsCleAEF))
                                        itr.remove();}}})

                        .setNegativeButton("Non", new DialogInterface.OnClickListener() {
                            @TargetApi(11)
                            public void onClick(DialogInterface dialogInterface, int which) {
                                Context context = getApplicationContext();
                                int duration = Toast.LENGTH_LONG;
                                Toasty.warning(context, "Annonce non supprimée", duration).show();
                            }
                        });
                if (!isFinishing()) {
                    dialog.show();
                }
            }
            else{
                Context context = getApplicationContext();
                int duration = Toast.LENGTH_LONG;
                Toasty.warning(context, "Vous n'êtes pas propriétaire de l'annonce: vous ne pouvez pas la supprimer", duration).show();}}

I’ve solved my problem, replacing if/else interleaved. I’ve replaced them by switch, case break an now it’s run OK