AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Confirm Delete"); builder.setMessage("Are you sure you want to delete this file?"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Delete file logic } }); builder.setNegativeButton("No", null); AlertDialog dialog = builder.create(); dialog.show();
String[] options = {"Option 1", "Option 2", "Option 3"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select Option"); builder.setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Handle option selection } }); AlertDialog dialog = builder.create(); dialog.show();The android.app.AlertDialog class is part of the Android SDK library.