I recently found out that the iPhone keeps (at least on older versions) your location data in a data file:
http://petewarden.github.com/iPhoneTracker/#faq
I have an iPhone on iOS 6 but my consolidated.db doesn't have the CellLocation table. The only table that has Lat / Lon information is Fences, but it's empty.
Has Apple fixed the security hole and stopped recording the data?
UPDATE
I found this article saying that Apple promised to keep the data for a shorter time:
http://www.yourdailymac.net/2011/04/apple-the-iphone-is-not-logging-your-location/
I'd like something more certain about which iOS versions are affected.