title: how to set datepicker dialog in android to yesterday date
body: <p>I have a datepicker code which sets current date to datepicker dialog </p>
  
  <p>how can i set this date to yesterdays date, specially during ,month end will it keep  yesterdays date and previous month, for example if on 1st feb we check it should display 31st jan and from on 2nd feb should show 1st feb and so on.</p>
  
  <pre><code> final Calendar c = Calendar.getInstance();
          maxyear = c.get(Calendar.YEAR);
          maxmonth = c.get(Calendar.MONTH);
          maxday = c.get(Calendar.DAY_OF_MONTH);
  
  
  protected Dialog onCreateDialog(int id) {
          switch (id) {
          case DATE_DIALOG_ID:
              // set date picker as current date
              DatePickerDialog _date =   new DatePickerDialog(this, datePickerListener, maxyear,maxmonth,
                      maxday){
                  @Override
                  public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth)
                  {   
                      if (year &lt; 2014)
                          view.updateDate(2014, mmonth, mday);
  
                      if (monthOfYear &lt; 12 &amp;&amp; year == 2014)
                          view.updateDate(2014, 12, mday);
  
                      if (dayOfMonth &lt; 31 &amp;&amp; year == 2014 &amp;&amp; monthOfYear == 12)
                          view.updateDate(2014, 12, 31);
  
                      if (year &gt; maxyear)
                          view.updateDate(maxyear, maxmonth, maxday);
  
                      if (monthOfYear &gt; maxmonth &amp;&amp; year == maxyear)
                          view.updateDate(maxyear, maxmonth, maxday);
  
                      if (dayOfMonth &gt; maxday &amp;&amp; year == maxyear &amp;&amp; monthOfYear == maxmonth)
                          view.updateDate(maxyear, maxmonth, maxday);
  
                  }
              };
              return _date;
          }
          return null;
      }
  </code></pre>