title: how to populate the alertdialog from the values queried from database?
body: <p>Right now I can only see the fetched values when I press OK button of the dialog. But I want to see it when the alertdialog appears. I know I have put the display code inside the .setPositiveButton("OK", But even when I tried putting it before that, it didnt work. I some how have idea that i need to make use of this setview(addView) but dont know how. Please help me.</p>
  
  <pre><code>enter code here
  private void populateFields() {
      LayoutInflater inflater=LayoutInflater.from(this);
      final View addView=inflater.inflate(R.layout.add_country, null);
  
      new AlertDialog.Builder(this)
      .setTitle("Edit country/year")
      .setView(addView)
      .setPositiveButton("OK", 
      new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog,int whichButton) {
      Cursor c = 
           getContentResolver().query                                                                   (CONTENT_URI.buildUpon                                             ().appendPath(String.valueOf(mRowId)).build(), null, null, null, null);
      /* Read alert input */
      EditText editCountry =(EditText)addView.findViewById(R.id.editCountry);
      EditText editYear =(EditText)addView.findViewById(R.id.editYear);
      //System.out.println(c.getString(c.getColumnIndex("country")));
      editCountry.setText(c.getString(c.getColumnIndex("country")));
      editYear.setText(c.getString(c.getColumnIndex("year")));
                  }
                  })
      .setNegativeButton("Cancel",
          new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog,int whichButton) {
        // ignore, just dismiss
      }
  })
      .show();
  }
  </code></pre>