title: Using same AlertDialog box multiple times with one variable change
body: <p>In my application i want to use a <code>AlertDialog</code> boxes in several places. I can to this by using the code everywhere i want the <code>AlertDialog</code> box. But it seems like a waste because it's the same code with only one change. How can i use the same code for <code>AlertDialog</code> box by changing the variable?</p>
  
  <p>This is my code for <code>AlertDialog</code> Box</p>
  
  <pre><code>private void showInternetConenctionAlert(String alert, String title) {
      AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
      alertDialog.setMessage(alert);
      alertDialog.setTitle(title);
      alertDialog.setCancelable(false);
      alertDialog.setPositiveButton("Yes",
              new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
  
                      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(topten.getFile()));
                              activity.startActivity(intent);
                  }
              });
  
      alertDialog.setNegativeButton("No",
              new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
  
                      finish();
                  }
              });
      alertDialog.show();
  }
  </code></pre>
  
  <p>Here <code>onClick</code> for positive <code>Button</code> i've used</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(topten.getFile()));
                                      activity.startActivity(intent);
  </code></pre>
  
  <p>Here only thing that should be changed for me to use in other places is this.</p>
  
  <pre><code>topten.getFile()
  </code></pre>
  
  <p>What's the approach i should take to do this?</p>