title: Delete oldest File(s) in a directory until it is under a certain file size
body: <p>What I'm trying to accomplish is the following: Suppose I have a function that writes an image to a File directory (either SD or internal cache). After writing out the File, I perform a check to see if my image directory is within a certain total file size (right now, I'm using this <a href="https://stackoverflow.com/questions/4040912/how-can-i-get-the-size-of-a-folder-on-sd-card-in-android/5256100#5256100">function</a> to recursively calculate the directory's file size). If the file that I just added makes that directory too big, then what I want to do is keep deleting older files until we are just below that max file size.</p>
  
  <p>I was thinking of first sorting the File directory members from oldest first (via comparator, ascending order using this <a href="https://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified/4248059#4248059">example</a>), then convert the array into an ArrayList to get its Iterator, then while our directory file size is still above the max file size, and I still have files to iterate to, I delete the older files until I break out of that while loop. Is there a more efficient way of accomplishing this?</p>