Location, media and metadata · Lesson 2 of 4
Photos and videos: Photos.sqlite, MediaStore, EXIF and HEIC
10 min read
Photos and videos are often the core evidence in a case, and each one carries two sets of facts. The file itself holds embedded metadata written by the camera or app that created it: capture time, camera model, GPS position. The phone's media database holds what the operating system recorded about the file: when it was added, which app imported it, whether it was edited, hidden or deleted. This lesson explains where both are stored on iOS and Android, how to read them and how to convert their timestamps; lesson 6.3 uses them to decide where a picture came from.
Two layers of metadata
Treat every media item as two records that should agree:
- File metadata. EXIF and XMP inside JPEG and HEIC images, and QuickTime or MP4 metadata inside videos. It travels with the file when the file is copied, unless an app strips or rewrites it.
- Database metadata. Photos.sqlite on iOS and MediaStore on Android. It stays on the device and describes the item's life there: import, edits, albums, trash.
When they disagree, that is a finding to explain, not an error: a copied file keeps its EXIF while the database records a new import time.
File formats and embedded metadata
HEIC and JPEG
iPhones save photos by default in HEIF format, as .HEIC files, when Settings › Camera › Formats is set to High Efficiency; Most Compatible saves JPEG instead. HEIF is a container format in which the image is compressed with HEVC and EXIF is stored as a separate item inside the container. Most Android camera apps save JPEG. A Live Photo is a still image plus a short MOV video, paired by a shared identifier that ExifTool shows as ContentIdentifier in both files.
EXIF fields that matter
| Field | What it holds | Time base |
|---|---|---|
| DateTimeOriginal | Capture time, as text "YYYY:MM:DD HH:MM:SS" | Local time, no zone |
| OffsetTimeOriginal | Offset from UTC at capture, such as +01:00 (added in Exif 2.31, 2016) | Offset |
| SubSecTimeOriginal | Fractions of a second | Belongs to DateTimeOriginal (local time) |
| GPSLatitude, GPSLongitude | Position at capture | Not applicable |
| GPSDateStamp, GPSTimeStamp | Time recorded for the position fix | UTC |
| GPSHPositioningError | Horizontal error in meters, where written | Not applicable |
| Make, Model, Software, LensModel | Device, operating system version and lens | Not applicable |
DateTimeOriginal alone is ambiguous: it has no time zone. Without OffsetTimeOriginal or another source, you do not know which instant it describes. Android's documentation for MediaStore makes the same point: an image must define both DateTimeOriginal and OffsetTimeOriginal for its capture time to be placed reliably on the UTC timeline. GPS time stamps are in UTC. On some devices and for some fixes they come from a clock other than the device clock, so a difference between them and the capture time is worth investigating (lesson 6.4).
Video metadata
MOV and MP4 files store times in their movie header as seconds since 1904-01-01 00:00:00 UTC. The format intends these values to be UTC, but some cameras write local time, and ExifTool assumes no time zone unless you set its QuickTimeUTC option. With that option set, ExifTool prints the value converted to the workstation's local time zone, so run it on a workstation set to UTC or read the offset it prints. To convert to Unix time, subtract 2,082,844,800. For example, an illustrative value of 3855994327 is 2026-03-10 13:32:07 UTC. Apple devices also write QuickTime keys such as com.apple.quicktime.creationdate, which includes the UTC offset, com.apple.quicktime.location.ISO6709 for the position, and make, model and software keys.
Reading metadata with ExifTool
ExifTool is a free, open-source command-line tool that reads metadata from almost every media format. Useful options:
- exiftool -a -G1 -s IMG_0412.HEIC lists every tag, including duplicates, with its group and short tag name, so you can see whether a value came from EXIF, XMP, maker notes or QuickTime.
- exiftool -n shows raw numeric values, for example decimal coordinates instead of degrees, minutes and seconds.
- exiftool -ee extracts embedded data, such as timed GPS tracks in some videos.
- exiftool -csv -r on a folder exports tags for many files into one spreadsheet.
ExifTool changes nothing unless told to write, but work on copies and hash them before and after.
iOS: Photos.sqlite
Where it lives
On iOS, camera originals are stored in /private/var/mobile/Media/DCIM/, in folders such as 100APPLE, with names such as IMG_0412.HEIC. The library database is /private/var/mobile/Media/PhotoData/Photos.sqlite. It is a Core Data store; the main asset table is ZASSET on iOS 14 and later, and ZGENERICASSET on iOS 11 to 13. Two related tables are joined to it: ZADDITIONALASSETATTRIBUTES (ZASSET.ZADDITIONALATTRIBUTES = ZADDITIONALASSETATTRIBUTES.Z_PK) and ZEXTENDEDATTRIBUTES (ZASSET.ZEXTENDEDATTRIBUTES = ZEXTENDEDATTRIBUTES.Z_PK).
Key columns
| Table and column | Meaning |
|---|---|
| ZASSET.ZDIRECTORY, ZFILENAME | Folder and file name of the asset, such as DCIM/100APPLE and IMG_0412.HEIC |
| ZASSET.ZDATECREATED | Capture or creation date, Mac absolute time |
| ZASSET.ZADDEDDATE | When the asset was added to this library, Mac absolute time |
| ZASSET.ZLATITUDE, ZLONGITUDE | Position, if any |
| ZASSET.ZKIND, ZKINDSUBTYPE | Photo (0) or video (1), and a subtype |
| ZASSET.ZTRASHEDSTATE, ZTRASHEDDATE | Whether the asset is in Recently Deleted, and since when |
| ZASSET.ZHIDDEN, ZHASADJUSTMENTS | Hidden album; edited |
| ZADDITIONALASSETATTRIBUTES.ZORIGINALFILENAME | File name at import, which may differ from ZFILENAME |
| ZADDITIONALASSETATTRIBUTES.ZTIMEZONEOFFSET, ZTIMEZONENAME | Time zone recorded for the capture; the offset is in seconds |
| ZADDITIONALASSETATTRIBUTES.ZEXIFTIMESTAMPSTRING | The EXIF capture time as text |
| ZADDITIONALASSETATTRIBUTES.ZIMPORTEDBY, ZIMPORTEDBYBUNDLEIDENTIFIER | How and by which app the asset entered the library |
| ZEXTENDEDATTRIBUTES.ZCAMERAMAKE, ZCAMERAMODEL, ZLENSMODEL | Camera details copied from the file |
Apple does not document this schema. Meanings of numeric values come from community testing, mainly by Scott Koenig, whose queries are built into iLEAPP, and many are still labeled as under test. Report the stored number and cite the source for its meaning.
All dates are Mac absolute time. An illustrative ZDATECREATED of 794842327 converts to 2026-03-10 13:32:07 UTC. If ZTIMEZONEOFFSET is 3600, local capture time was 14:32:07 at UTC+01:00, which should match ZEXIFTIMESTAMPSTRING and the file's own DateTimeOriginal.
Recently Deleted, edits and changed dates
When a user deletes a photo, iOS does not remove it at once. The asset moves to the Recently Deleted album, where Apple says it stays for 30 days before permanent deletion; on current versions the album is unlocked with Face ID or Touch ID. In Photos.sqlite, ZTRASHEDSTATE changes from 0 to 1 and ZTRASHEDDATE records when. The file normally stays in its DCIM folder until the item is removed for good. After permanent deletion the row is deleted, but traces may remain in the -wal file or free pages (lesson 3.2), and thumbnails or cloud records may survive.
Edits in the Photos app are non-destructive. ZHASADJUSTMENTS becomes 1, and the ZUNMANAGEDADJUSTMENT table records the adjustment time (ZADJUSTMENTTIMESTAMP) and the editor (ZEDITORLOCALIZEDNAME). The original stays in DCIM. Apple's developer documentation states that Photos saves adjustment data, a description that lets the edit be reconstructed or reverted, along with the modified image or video, and keeps only the most recent adjustment. Apple does not document the layout, but in practice the rendered version is found under /private/var/mobile/Media/PhotoData/Mutations/, in a folder that mirrors the original's DCIM path, for example PhotoData/Mutations/DCIM/100APPLE/IMG_0412/Adjustments/FullSizeRender.jpg. Confirm the layout in the extraction for the iOS version you examine. Users can also change a photo's date, time and location with the Adjust option in its info panel, and revert them later. A ZDATECREATED that disagrees with the file's DateTimeOriginal may be the result of such a change.
With iCloud Photos and Optimize iPhone Storage on, the device may hold only a smaller version of an older photo, with the original in iCloud. Some features keep separate libraries with their own Photos.sqlite, such as Syndication.photoslibrary for content shared with you in Messages and, since Image Playground arrived in iOS 18, a library for its creations under Library/Photos/Libraries/Application/com.apple.GenerativePlayground/.
Android: MediaStore
Where it lives
Android indexes shared media in MediaStore, a system database maintained by the media provider. On Android 11 and later the provider is an updatable module. Its database is /data/user/0/com.google.android.providers.media.module/databases/external.db on devices with Google's module, or /data/user/0/com.android.providers.media.module/databases/external.db on builds that use the AOSP module. Android 10 and earlier use /data/user/0/com.android.providers.media/databases/external.db. It sits in CE storage; the files sit in shared storage, such as /data/media/0/DCIM/Camera/ (/sdcard/DCIM/Camera/ to the user). Samsung devices also run Samsung's own media provider, with a separate database, media.db, covered in lesson 3.7.
The files table
| Column | Meaning | Unit |
|---|---|---|
| _data, _display_name, relative_path | Full path, file name and folder | Text |
| mime_type | Declared type, such as image/jpeg | Text |
| datetaken | Capture time from EXIF or video metadata | Unix milliseconds |
| date_added | When the item was first added to MediaStore | Unix seconds |
| date_modified | File's last-modified time when indexed | Unix seconds |
| owner_package_name | App that contributed the item; may be empty | Text |
| is_pending, is_trashed | Still being written; in the trash | Flag |
| date_expires | When a pending or trashed item will be deleted | Unix seconds |
Note the mixed units. A capture at 2026-03-10 13:32:07 UTC appears as datetaken 1773149527000, while an item added at 2026-03-11 09:44:50 UTC appears as date_added 1773222290. date_added describes when MediaStore indexed the file, not when the picture was taken, and a rescan or restore can create fresh rows.
Trash on Android
Since Android 11, apps can move media to a system trash. MediaProvider then sets is_trashed to 1, calculates date_expires, by default 30 days later, and renames the file to the form .trashed-<expiry in Unix seconds>-<original name>. A photo trashed at 2026-03-11 09:52:03 UTC would be renamed with the number 1775814723 (2026-04-10 09:52:03 UTC). Expired items are deleted automatically, typically during the next idle period. Gallery apps do not all use this mechanism: Samsung Gallery keeps its own trash, and Google Photos has its own bin. Check each gallery app the device uses (lessons 3.6 and 3.7).
Applying this to the Corvane case
On Lena's iPhone, the examiner finds three rows in ZASSET for IMG_0412.HEIC to IMG_0414.HEIC in DCIM/100APPLE. All three have ZTRASHEDSTATE 1 and a ZTRASHEDDATE on Day 2: they were moved to Recently Deleted that day and were still there at acquisition on Day 9, inside the 30-day period. ZDATECREATED values are on Day 1, 34 seconds apart from one photo to the next; ZTIMEZONEOFFSET is 3600; and ZEXTENDEDATTRIBUTES shows Apple as make and iPhone 14 as model. ExifTool on the files shows matching DateTimeOriginal values with OffsetTimeOriginal +01:00 and GPS coordinates near the office.
On Victor's Galaxy phone, MediaStore lists three JPEG files, IMG-20260311-WA0001.jpg to IMG-20260311-WA0003.jpg, with date_added values on Day 2 and owner_package_name com.whatsapp, in WhatsApp's own media folder. These rows show that WhatsApp wrote the files; they do not show that Victor chose to save them. Lesson 6.3 explains why their metadata looks very different from Lena's originals.
Exam focus: Know where Photos.sqlite and MediaStore's external.db are stored, the main tables and columns, and their timestamp units: Mac absolute seconds on iOS, and a mix of Unix seconds and milliseconds on Android. Know how deletion is recorded on both platforms, including ZTRASHEDSTATE and the .trashed- file names. Understand that DateTimeOriginal has no time zone and needs OffsetTimeOriginal or another source.
Practice questions
Check your understanding. These questions do not count towards the exam.
Sign in to save your progress and continue where you left off. It is free. Sign in