title: Fragment already added: DateDialog
body: <p>I have make my <code>editText</code> clickable. Once it is clicked, it will display <code>DatePicker dialog</code>. </p>
  
  <pre><code> public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.information);
   date = (EditText) findViewById(R.id.date);
   dialog=new DateDialog();
   date.setOnClickListener(this);
  
          public void onClick(View arg0) {
          FragmentTransaction ft = getFragmentManager().beginTransaction();
          dialog.show(ft, "DatePicker");
          }
  
   public static class DateDialog extends android.app.DialogFragment implements DatePickerDialog.OnDateSetListener {
          public DateDialog() {}
  
           public Dialog onCreateDialog(Bundle savedInstanceState)
          {
              final Calendar c=Calendar.getInstance();
              int year=c.get(Calendar.YEAR);
              int month=c.get(Calendar.MONTH);
              int day=c.get(Calendar.DAY_OF_MONTH);
              return new DatePickerDialog(getActivity(),this,year,month,day);
          }
  
          public void onDateSet(DatePicker view,int year, int month, int day)
          {
              String date1=day+"-"+(month+1)+"-"+year;
              date.setText(date1);
              date2= date.getText().toString();
              return ;
           }
      }
  </code></pre>
  
  <p>If I accidentally double click on the <code>editText</code>, the app crashed and shows <code>Fragment already added</code> error as below. </p>
  
  <pre><code>11-26 10:16:04.745    2348-2348/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.example.project.myapplication, PID: 2348
      java.lang.IllegalStateException: Fragment already added: DateDialog{d1ca446 #0 DatePicker}
              at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1219)
              at android.app.BackStackRecord.run(BackStackRecord.java:715)
              at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
              at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
              at android.os.Handler.handleCallback(Handler.java:739)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:148)
              at android.app.ActivityThread.main(ActivityThread.java:5417)
              at java.lang.reflect.Method.invoke(Native Method)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p>Does anyone know how to fix this ? Thanks </p>