Create a method in your separate class with the following parameters:
public static void showAlert(Context context, String title, String message){
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
alertDialog.setTitle(title);
alertDialog.setMessage(message);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
Then to call it, do the following:
SuaClasseOndeEstaoMetodo.showAlert(this, "Erro", "A imagem não pode ser carregada");