This is probably your trickiest method.  I'm not convinced that it works correctly.  

When we enumerate the DB, we get pictures from newest to oldest.  But when we scan the card to find new photos, there are no guarantees about the order they arrive in.  So you'll need to make sure that you aren't assuming chronological order.  If photos are scanned out of order, I think your algorithm has to change to allow groups to be split.  Imagine getting 5 photos from October and then 6 photos from November.  They'd all end up in one group, I think.  Then if we get another October photo, we need to split the Oct-Nov group into two separate groups.

Enumeration will be by far the most common case and you'll get photos from newest to oldest, and they will almost always be inserted at the end.  So you change change the addItem algorithm so that its start comparing at the end of the array rather than at the start.  Otherwise, you end up with an O(n*n) algorithm.

If I was working on this, I think I'd give the Group object a canContain(item) method. Rather than a boolean true/false, it would have to have three possible return values:

  yes: this is unambiguously the right group for the item: the month and year matches
  no: unambigously the wrong group: the group has > 6 items and the month is different
  maybe: you'd get this when a group isn't full yet.

What is unclear to me is how to deal with the maybe cases.  If we've got existing groups for September and November and then we get a photo from October, which group goes it get added to?  
  
Actually, it is unclear to me whether this proposed canContain() method should ever return 'no'.  I suppose that any group can contain new photos.  It almost seems like for each photo, you'd need to scan all existing groups to see if there is one that returns 'yes'.  And if not, you'd then have to scan again to find out which group it fits best in.

The intent of the multi-month groups in the spec is to avoid having lots of small under-filled groups.  Obviously in the case where there are fewer than 6 photos on the device, we'll have an underfilled group.  And I think that the newest items should probably be allowed to  be in an unfilled group.  That is if you have 10 photos from October, and then on November 1st you take two photos. I don't think you should see an October-November group.  You should just see a November group with two items in it.

And deleting photos is going to be a mess if we have to recompute group boundaries on deletion.  Yuck.

I think I'm going to recommend that we push back on the UX and just do monthly groups.  If you take fewer than 6 photos a month then you probably aren't using gallery much either, and the sub-optimal grouping won't be an issue.