Messaging and social apps · Lesson 1 of 5
How messaging apps store data: local databases, encryption, backups and cloud
10 min read
Messaging apps are often the center of a mobile case, because they hold what people said to each other, the files they exchanged and when. They are also the part of the phone that changes fastest: major apps ship updates every few weeks, and each stores data in its own way. Before looking at individual apps, an examiner needs a general model of where a message can exist, how each copy is protected and what that means for acquisition. This lesson gives you that model; lessons 5.2 to 5.5 apply it to specific apps and to deleted data.
Where a message can exist
One message can leave copies in several places at once:
- The sender's phone, in the app's local database, with any attachment stored as a separate file.
- The service's servers, which relay the message. Some keep content only until delivery; others keep the full history. Almost all keep metadata.
- The recipient's phone, with its own database and its own copy of the attachment.
- Linked devices, such as a desktop app, tablet or second phone on the same account, each with its own copy.
- Backups, made by the app itself or by the operating system, stored on the phone, on a computer or in the cloud.
- Side traces, such as notifications, thumbnails and keyboard caches (lesson 5.5).
The phone in front of you is rarely the only source, and its copy may not be the most complete one. A message missing from one copy may survive in another.
How apps store data on the device
Each app stores its data inside its own sandbox (lesson 3.1 for Android, lesson 4.1 for iOS). Within that space, apps use a small number of storage formats.
SQLite databases
Most messaging apps keep messages, chats and contacts in SQLite, a single-file database engine built into both Android and iOS. A typical messaging database has a table of messages, a table of conversations and a table of contacts or identifiers, joined by numeric keys. Many run in write-ahead logging (WAL) mode, where recent changes sit in a separate -wal file until they are merged into the main file. Always process the main file, the -wal file and the -shm file together; lesson 3.2 explains why, and how deleted records survive.
Other formats
- Realm is an object database used by some apps instead of SQLite. Its files often end in .realm and need a Realm-aware viewer or parser.
- LevelDB is a key-value store kept as a folder of .ldb, .log, MANIFEST and CURRENT files. On Android, apps that show web content through the system WebView keep Local Storage and IndexedDB data in LevelDB folders.
- Property lists and XML. iOS apps keep settings in plists (lesson 4.2); Android apps keep them in shared_prefs XML files.
- Serialized blobs. Many apps store parts of a message in a database column as Protocol Buffers (protobuf), JSON or an app-specific binary format, so a database can open in any SQLite browser and still hide its key content inside a blob.
Media, caches and preferences
Attachments are usually separate files, with the database holding a relative path to each. Media can live in the app's private storage or, on Android, in shared storage where the gallery can see it. Caches hold downloaded images, link previews and profile pictures. Preferences hold the account's phone number or user ID and backup settings, and are often the quickest way to identify the account.
Two different kinds of encryption
Two separate protections are often confused.
End-to-end encryption protects messages in transit
End-to-end encryption (E2E) means a message is encrypted on the sender's device and can only be decrypted on the recipients' devices. The server relays ciphertext it cannot read. WhatsApp and Signal use E2E for all chats; Messenger made it the default for personal chats from December 2023; Telegram uses it only in optional secret chats, while its ordinary cloud chats are encrypted between each device and Telegram's servers.
E2E does not mean the message is encrypted on the phone. The app decrypts it so the user can read it and stores it in its local database. What protects that stored copy is a separate question.
At-rest encryption protects the stored copy
A stored message can have up to two layers of protection:
- Operating system encryption. iOS Data Protection (lesson 1.2) and Android file-based encryption (lesson 1.3). An acquisition that reads the file system of an unlocked or after-first-unlock (AFU) device receives these files already decrypted by the operating system. On a locked AFU iPhone the exception is data in class A (Complete Protection), which is readable only while the phone is unlocked (lesson 1.2).
- App-level database encryption. Some apps encrypt the database file itself, most often with SQLCipher, an open-source extension of SQLite that encrypts every page with AES. Signal does this on both platforms, and Telegram's iOS client does it too. A SQLCipher database looks like random data, apart from any header the app leaves readable, and cannot be opened without its key.
WhatsApp is the contrast: E2E in transit, but msgstore.db (Android) and ChatStorage.sqlite (iOS) are ordinary SQLite files protected only by the operating system, so a full file system extraction of an AFU phone gives readable messages.
Where app keys live
An app that encrypts its database needs to keep the key somewhere it can find it every time it starts. Well-designed apps use the platform's protected key stores:
- Android Keystore. Apps can create keys held in the Trusted Execution Environment or a StrongBox chip that cannot be exported; the app asks the Keystore to encrypt or decrypt with them. Signal stores its database key in a preferences file, sealed (encrypted) with such a key.
- iOS keychain. Apps store secrets as keychain items with an accessibility class, such as available after first unlock, and the option to keep them on this device only (lesson 1.2).
A key held in the Android Keystore or the iOS keychain cannot simply be copied off the phone as a file. It has to be recovered on the device, by an extraction method privileged enough to use the Keystore or dump the keychain, usually only while the device is AFU. Not every app does this: Telegram for iOS, for example, keeps its database key in a file beside the database (lesson 5.3). The extraction report should state whether the key was recovered.
| App | In transit | Local database | Database key held in |
|---|---|---|---|
| E2E, all chats | Plain SQLite (OS protection only) | Not applicable | |
| Signal | E2E, all chats | SQLCipher | Android Keystore or iOS keychain |
| Telegram cloud chats | Client to server | Android: plain SQLite; iOS: SQLCipher | iOS: a key file in the app group container |
| Telegram secret chats | E2E | Same databases as above | As above |
Backups and their encryption
Backups matter as a source when the phone cannot be accessed and as a source of data later deleted from the phone. Four kinds are common.
- App backups on the device. WhatsApp on Android writes encrypted local backups to shared storage (lesson 5.2). Signal can write on-device backups protected by the user's recovery key (older Android versions: a 30-digit passphrase), on Android and, in recent versions, on Desktop and iOS (lesson 5.3).
- App backups in the cloud. WhatsApp backs up to Google Drive on Android and to iCloud Drive on iOS. Since 2021 users can make these backups end-to-end encrypted with a password or a 64-digit key, and since late 2025 with a passkey. When a password is used, the backup key is held in an HSM-based vault (a hardware security module) that limits guessing. Signal offers Secure Backups, end-to-end encrypted with a 64-character recovery key, rolled out on Android from September 2025 and on iOS from November 2025.
- Operating system backups. On iOS, a computer backup and iCloud Backup include app data unless the app excludes it. Telegram and Signal keep their message databases out of them, and WhatsApp states that its chat history is excluded from the iPhone's device backups once its own end-to-end encrypted backup is turned on. On Android, the system can back up as much as 25 MB of each app's data to the user's Google account and can copy app data to a new phone during setup. An app can opt out or exclude files, so never assume that its message database is included (lessons 2.3 and 2.7).
- Server-side history. For Telegram cloud chats, the "backup" is the account itself, and accessing it is a legal question as much as a technical one (lesson 2.7).
Record what the device's preferences say about backups: account, last backup time, frequency and encryption. These values tell the legal team what to request, even when you cannot read the backup yourself.
Multi-device and linked devices
Modern messaging accounts are rarely tied to one device. The model differs by app:
- WhatsApp has one primary phone and up to four linked devices: computers, tablets or, since 2023, other phones. Each connects independently, keeps its own database and receives an encrypted copy of recent history when it is linked.
- Signal has one primary phone and up to five linked devices. Since January 2025, a new linked device can receive an encrypted transfer of message history plus the last 45 days of media. In 2026 Signal began allowing a second phone to be linked as well.
- Telegram cloud chats are on every device logged in to the account, because the history lives on the server; secret chats exist only on the two devices that created them.
Two consequences follow. A message marked as sent by the account in one device's database may have been typed on another device, so the sending device is a separate finding. And a linked computer can hold messages deleted from the phone, or the other way round.
What the provider can hold
Even E2E services keep records such as registration details, IP addresses, connection times and, for some services, contact lists and group memberships, but usually not E2E content. They are obtained through legal process and can confirm or challenge the device's timeline (lesson 2.7).
Applying this to the Corvane case
Before touching either phone, the examiner lists the copies that may exist of the Day 2 WhatsApp conversation:
- Lena's ChatStorage.sqlite and media, and Victor's msgstore.db and media;
- any WhatsApp Desktop or Web session that either of them had linked;
- any WhatsApp backup in Lena's iCloud Drive, and Victor's local and Google Drive backups;
- the computer backup of Lena's iPhone on her work laptop.
The list guides requests to the legal team and explains in the report why each source was or was not examined. It also sets expectations. The laptop backup was made before Day 1: it holds an earlier ChatStorage.sqlite, which shows that WhatsApp had not excluded its chat history from that backup, but it cannot contain the Day 2 messages.
Exam focus: Be able to explain the difference between end-to-end encryption in transit and encryption of the stored copy. Know why a WhatsApp database is readable in a full file system extraction while a Signal database needs a key held in the Keystore or keychain. Know the main kinds of backup, how app-level end-to-end encrypted backups change what is available, and why linked devices complicate attribution.
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