title: Android get previous week dates
body: <p>I have some code that gets the current week and loads it into an array:</p>
  
  <pre><code>DateFormat format = new SimpleDateFormat("M-dd");
  calendar = Calendar.getInstance();
  calendar.setFirstDayOfWeek(Calendar.SUNDAY);
  calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
  
  days = new String[7];
  for (int i = 0; i &lt; 7; i++)
  {
  calendar.add(Calendar.DATE, 1);
  days[i] = format.format(calendar.getTime());
  }
  </code></pre>
  
  <p>I then have some code that runs on the selection of a button that will retrieve the previous week dates and loads them into an array:</p>
  
  <pre><code>DateFormat format = new SimpleDateFormat("M-dd");
  
  days = new String[7];
  
  for (int i = 0; i &lt; 7; i++)
  {
  calendar.add(Calendar.DATE, -1);
  days[i]=format.format(calendar.getTime());
  }
  </code></pre>
  
  <p>My issue is that it will load for example: 5-22-17, 5-23-17, 5-24-17, 5-25-17, 5-26-17, 5-27-17, 5-28-17  into the initial load for the first week and then when I click on my Previous button to run the previous button code it only goes back 1 day: 5-21-17 - 5-27-17. If I click it again it then goes back a whole week: 5-14-17 - 5-20-17.</p>
  
  <p>How can I fix my code to retrieve the previous week days correctly on the first click?</p>