How can i put alert dialog box in loop specially in for loop Android
<p>I want to add different dialog box for different contacts ..!! and i want create in following for loop and here is my code ..!!  </p>

<p>public class CallActivity extends Activity{</p>

<pre><code>sqlAdapter adapter;
Context mContext; 
String Birthdate, CurrentDate, ctName = "Unknown", phNumber = "Unknown";

@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reminder);

    Calendar cal = Calendar.getInstance();
    int date = cal.get(Calendar.DAY_OF_MONTH);
    int month = cal.get(Calendar.MONTH)+1;
</code></pre>

<p>/* For geting Current Date */</p>

<pre><code>    if(date&lt;10 &amp;&amp; month&lt;10){
        CurrentDate = "0"+month+"-0"+date;
        Toast.makeText(getBaseContext(), "CurrentDate : " + CurrentDate, Toast.LENGTH_LONG).show(); 
        }else if(month&lt;10 &amp;&amp; date&gt;10){
            CurrentDate = "0"+month+"-"+date;
            Toast.makeText(getBaseContext(), "CurrentDate : " + CurrentDate, Toast.LENGTH_LONG).show(); 
        }else if(month&gt;9 &amp;&amp; date&lt;10){
            CurrentDate = month+"-0"+date;
            Toast.makeText(getBaseContext(), "CurrentDate : " + CurrentDate, Toast.LENGTH_LONG).show(); 
        }else {
            CurrentDate = month+"-"+date;
            Toast.makeText(getBaseContext(), "CurrentDate : " + CurrentDate, Toast.LENGTH_LONG).show(); 
        }

    adapter = new sqlAdapter(getBaseContext());
    adapter.openToRead();
    ArrayList&lt;ContactDetails&gt; cDetails = adapter.getContactDetails(CurrentDate);
    adapter.close();
</code></pre>

<p>/* this is for loop where i want to generate alert dialog box for different contacts */</p>

<pre><code>    for (int i = 0; i &lt; cDetails.size(); i++) {
        ctName = cDetails.get(i).Name;
        adapter.openToRead();
        phNumber = adapter.getcNumber(ctName);
        adapter.close();
        alertforcall(getBaseContext(),ctName,phNumber);
    }   
}

public void alertforcall(Context context, String Name, final String ctNumber){
    mContext = context;

    AlertDialog alert = new AlertDialog.Builder(CallActivity.this).create();
    alert.setIcon(R.drawable.ic_launcher);
    alert.setTitle("");
    alert.setMessage("Are you sure want to call " + Name +"? " );

    alert.setButton("No", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            finish();

        }
    });

    alert.setButton2("Yes", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String phoneNumber = "tel:" + ctNumber;
            Intent intent = new Intent(Intent.ACTION_CALL, Uri
                    .parse(phoneNumber));
            startActivity(intent);
            finish();           
        }
    });
    alert.show();
}
</code></pre>
