An Android AlertDialog Builder example

Mostly because I have a bad memory, here’s an Android AlertDialog Builder example:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Exception!").setMessage(t.toString()).setPositiveButton("OK", null).show();

Here’s another one that shows you can use a newline character in the string message:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
String msg = "After all of 'Clearing cache' messages stop, \nplease restart the app to completely clear the cache.";
builder.setTitle("Please Restart").setMessage(msg).setPositiveButton("OK", null).show();