Storing data on a phone is the easy part. SQLite has handled it for years. The harder decision is how changes travel between the device and a server, and that choice tends to outlive the first version of the app.
For a single-user app that works offline, SQLite through Room or Drift is enough. Shared real-time data points to Cloud Firestore, and Couchbase Lite is the better fit when the app stays offline for hours.
Sync is also where vendor risk piles up. MongoDB removed Atlas Device Sync on September 30, 2025, and apps built on it had to move to an alternative solution or remove sync.
MySQL and PostgreSQL running on a server sit behind an API, so they fall outside the ranking.
Which database is best for a mobile app?
It depends on the app type, and no single database wins across all of them. SQLite through Room or Drift covers single-user offline apps. Cloud Firestore handles shared real-time data, while an offline-first sync database suits apps that stay disconnected for hours.
MySQL, PostgreSQL, and Memcached run on a server behind an API. They aren’t mobile databases, so they’re left out of this comparison.
| Option | Data lives | Offline | Best fit |
|---|---|---|---|
| SQLite with Room or Drift | Device | Always local | Single-user apps |
| Core Data or SwiftData | Device | Always local, optional iCloud sync | iOS-only apps |
| Cloud Firestore | Cloud plus local cache | Built in | Chat, collaboration, field apps |
| Couchbase Lite | Device plus Sync Gateway | Offline-first | Long offline stretches |
Flutter’s database guide classes on-device SQLite as always local, and it describes Firestore’s offline reads and writes as built in.
Make the decisions in a set order: storage location first, then data model, then sync layer. Teams that start from a brand name often end up with a document store holding relational data, and untangling that later is no fun.
For scale, the SQLite project estimates over one trillion SQLite databases in active use, extrapolated from more than 4.0 billion smartphones that each hold hundreds of database files (sqlite.org).
With that kind of reach, local storage rarely needs a debate. If the app has one user and no shared data, a local SQLite database beats any cloud product on cost and on complexity.
Should app data live on the device, in the cloud, or both?
Both, as soon as more than one device touches the data. Local-only storage works for a single-user app. Cloud-only fails whenever the signal drops. A local-first hybrid keeps reads and writes on the device and lets a sync layer catch the server up afterward.
A mobile database runs on the device and syncs with a server. A server database such as MySQL or PostgreSQL has no mobile client, so it sits behind an API.
Local storage

Reads and writes work with no network, which is the whole appeal. The catch is that nothing is shared across devices or users, and the data is gone on uninstall unless a backup or sync service exists. Flutter’s guide says exactly that about local SQLite and key-value data.
Room is built for on-device persistence. For multi-device sync, Android’s documentation points to WorkManager with a custom backend, or to managed options such as Cloud Firestore.
Cloud storage

Cloud-only storage is the simplest architecture to build. Anything shaped like a purely cloud-based app also inherits every network failure.
DZone’s mobile database refcard notes that apps relying only on a back-end cloud database are subject to network disruption and latency.
A self-hosted MySQL or PostgreSQL server needs a RESTful API between it and the phone. Managed products such as Firestore and Supabase ship client SDKs instead.
Cloud-only is the right call for dashboards and admin tools. It is the wrong call for anything used on a train.
Hybrid and local-first storage
Cloud Firestore is the clearest hybrid example. Offline persistence is on by default on Android and Apple platforms and off by default on the web, and the Firebase docs’ code sample sets the default cache threshold at 100 MB.
Local changes sit in a write queue and upload when the device reconnects. Conflicts are where it gets awkward. When several changes touch the same document, the last write wins, so one of two offline edits to the same field is overwritten.
Flutter’s guide suggests mixing approaches, with Firestore for shared data and shared_preferences for device-specific settings such as a dark mode toggle.
SQL, NoSQL, or key-value: which data model fits a mobile app?

Match the model to the shape of the data.
Relational tables suit records that join and carry constraints. SQLite, Room, Drift, and GRDB all sit here, with a strict schema, joins, and transactions. Room verifies SQL queries at compile time, and Drift generates typed Dart rows from SQL at compile time too.
Documents fit nested records that change shape. Firestore stores NoSQL documents and collections. Couchbase Lite is an embedded NoSQL JSON document database queried with SQL++.
ObjectBox is the object database option, an on-device database with vector search and out-of-the-box data sync, built around whole object graphs. Key-value storage (MMKV, Hive, shared_preferences) handles small values with no joins.
Document stores give up joins. Flutter’s guide sends relational workloads such as ecommerce, booking, finance, and inventory to Firebase SQL Connect, which sits on PostgreSQL, rather than to Firestore.
Key-value storage runs out of road quickly. shared_preferences is meant for small, simple data such as preferences, while tokens and encrypted records belong in flutter_secure_storage.
MMKV, the key-value framework used in WeChat, relies on mmap and protobuf. Hive is a pure Dart key-value store with AES-256 encryption.
Check Hive’s health before committing. Its pub.dev page lists 2.2.3 as the latest stable release, published about four years ago.
Schema changes cost differently depending on the model. Room lists streamlined migration paths as a core benefit, and Drift ships migration utilities. Document stores skip table migrations but push shape changes into app code.
Which local databases fit Android, iOS, Flutter, and React Native?
Each platform has a default, and the default is usually right. Android developers start with Room over SQLite. On iOS the choice is SwiftData, Core Data, or GRDB. Flutter leans on Drift, with Hive or ObjectBox for non-relational data, and React Native has WatermelonDB. Apps that ship on several platforms at once should look at ObjectBox or Couchbase Lite.
Android

Room is an abstraction layer over SQLite, and Google’s documentation recommends it over calling the SQLite APIs directly. Compile-time verification of SQL queries is the main draw, along with streamlined migration paths. Annotations also cut repetitive boilerplate.
The downside is that Room is on-device only, so multi-device sync needs a backend you wire up yourself. I’d still pick it on Android without much debate.
iOS

SwiftData is Apple’s declarative persistence framework, built on Core Data, with optional iCloud sync across a person’s devices. It requires iOS 17, macOS 14, or later. Core Data, the older object graph framework underneath it, is the pick when the app still supports earlier OS versions.
GRDB is a toolkit for SQLite databases with a focus on application development. Choose it when you want direct SQL control instead of an object graph.
One thing to keep in mind: iCloud sync ties the data to Apple devices. Cross-platform sync needs a different layer.
Flutter
Flutter has no built-in database. sqflite gives direct SQL queries, and Drift gives type-safe queries, reactive streams, and schema migrations.
| Package | Strength | Watch out for |
|---|---|---|
| Drift | Typed SQL, reactive streams, migrations | Relational model only |
| Hive | Pure Dart, AES-256 encryption | Latest stable release about four years old |
| Isar | Queries and object links | README flags v4 as not production ready |
Isar’s README tells production users to stay on stable version 3 and does not state whether the project is actively maintained. Verify its status yourself before building on it.
React Native
WatermelonDB is a reactive database framework for React and React Native, built on SQLite and running on iOS, Android, Windows, web, and Node.js. It’s offline-first by design and syncs with your own backend. The server half of that sync is yours to build, though.
Several platforms at once
ObjectBox and Couchbase Lite cover more than one platform from a single engine. Teams doing cross-platform app development often want one data layer instead of three.
ObjectBox has bindings for Java, C, C++, Kotlin, Go, Swift, Dart, and Python. The vendor claims “10x Faster than any alternative”, which is a vendor claim until you benchmark it on your own data.
Couchbase Lite 4.1 has official support for Android, iOS, .NET, C, and React Native, while Flutter support is community-maintained and not official.
Realm is a stranger case. MongoDB deprecated Atlas Device Sync, and the on-device database continues as an open source project. Local storage survives. The sync service does not.
Which cloud databases and sync backends work for mobile apps?

Cloud Firestore is the default for shared, real-time data on a managed backend, and Flutter’s guide recommends it over Realtime Database for new apps. Supabase suits teams that want Postgres. Sync-first options such as Couchbase Mobile, Ditto, PowerSync, and ObjectBox Sync suit apps that stay offline for long stretches.
Firestore, Realtime Database, and Supabase are managed backend as a service platforms. The vendor runs the servers, and the app reaches them through a client SDK.
Firebase: Firestore and Realtime Database

Realtime Database caches 10 MB of synced data on the device by default and purges the least recently used data when the cache fills, according to the Firebase documentation. It does well at low-latency sync for small, frequent state such as presence indicators. Offline transactions are queued but not kept across app restarts, which is worth knowing before you rely on them.
Firestore turns offline persistence on by default on Android and Apple platforms and is secured with Security Rules. Its weak spot is last write wins on same-document conflicts.
Supabase
Every Supabase project is a full Postgres database. Its features page lists Flutter and Swift client libraries as generally available and no Kotlin library.
The Flutter quickstart fetches data over the network on each page load and says nothing about offline caching. Plan the offline layer separately. You get full SQL and a portable database, and in exchange you build or add the offline behavior yourself.
Amplify DataStore
Amplify Gen 1 is in maintenance mode. It reaches end of life on May 1, 2027, per the AWS documentation (as of November 2026).
DataStore connects to an AppSync backend and syncs locally saved data using GraphQL. New projects are told to use Amplify Gen 2.
The offline-first sync with a local store is the good part. The catch comes with migration: AWS’s guide moves apps from DataStore to the Amplify API category, and local caching and offline support become optional extras from third-party packages.
Couchbase Mobile

Couchbase Mobile pairs Couchbase Lite on the device with Sync Gateway for bi-directional sync with Couchbase Server. Couchbase reports that Ryanair’s booking app gained 60% in performance with it, a vendor-published figure.
It comes with built-in local storage encryption, peer-to-peer sync between devices, and revision control with conflict resolution. Cloud sync does need Sync Gateway and Couchbase Server on the backend, and Flutter support is community-maintained.
Sync-first services
MongoDB’s Device Sync migration guide lists Ditto, PowerSync, and ObjectBox among the replacements for Atlas Device Sync.
Ditto is a real-time edge sync platform for mobile, web, IoT, and server apps. PowerSync keeps in-app SQLite synced with your backend, with Postgres and MongoDB supported and MySQL in beta, and its SDKs include Dart/Flutter, Kotlin, Swift, and React Native. ObjectBox Sync is bi-directional and offline-first, with the cloud optional.
Firestore and Couchbase Lite carry offline capability in the database itself. PowerSync puts it in a sync layer over local SQLite. If neither fits, you write it, for example with Room, WorkManager, and a custom backend.
Self-hosted options
Appwrite is an open-source backend platform with Databases, Auth, Storage, and Realtime, available on Appwrite Cloud or self-hosted. Its quick-start guides cover Flutter, Swift, Kotlin, and React Native.
PouchDB replicates with CouchDB one way or both ways, and live replication pushes changes as they happen. When changes conflict, CouchDB picks a deterministic winner and keeps the losing revisions, so the app can surface them.
PouchDB targets the browser, so it fits web and hybrid apps. For native smartphone sync in the Couch family, the PouchDB guide points to Couchbase Lite.
Self-hosting gives you full control over data and hosting. You pay for it in servers you patch and scale yourself.
How does data sync work, and how are conflicts resolved?
Sync starts with a write to the local database, which the app then queues and pushes to the server. When two devices changed the same record, a conflict rule decides which version survives.
Android’s offline-first guide makes the local database the source of truth. Reads come only from local storage, and a repository keeps the network data source in step.
Write strategies

Online-only writes hit the network first and then update local storage, which fits bank transfers and other near-real-time transactions. Queued writes enqueue the change and drain the queue with exponential backoff once the device is online, a good match for analytics and logging.
Lazy writes go to local storage first, and the network call is queued afterward. The guide calls this the right choice for data the app cannot lose, such as offline to-do items, and it requires conflict handling.
Sync strategies
| Strategy | Offline tolerance | Catch |
|---|---|---|
| Pull-based | Brief to intermediate gaps | Heavy data use, scales poorly with relational data |
| Push-based | Offline indefinitely | Conflict versioning is nontrivial, server must support sync |
| Hybrid | Depends on the data | Two code paths to maintain |
The guide’s own hybrid example pulls a social feed and pushes profile data. The right mix, it says, depends on product requirements and the technical infrastructure you have.
Conflict resolution
Last write wins is the common mobile default. Devices attach timestamps to writes, and the server discards anything older than its current state.
Because those timestamps come from the devices, a phone with a wrong clock can overwrite newer data.
Couchbase Lite documents a stricter ruleset. For replication conflicts, the change with the most revisions wins. Direct saves from the app use last write wins. Deletes always win in both cases, and custom resolvers, available since version 2.6, can pick local, remote, or merge.
That delete rule has a side effect. An offline edit cannot revive a record another user removed. If deletes must be reversible, store a deleted flag instead of removing the row.
Couchbase also recommends one shared resolver across all replicators, because pending conflicts can lose data otherwise.
What happened when Realm’s Atlas Device Sync was shut down?

MongoDB deprecated Atlas Device SDKs in September 2024 and removed Device Sync on September 30, 2025, so apps had to move to another sync provider or drop sync. The Realm database survived. The sync, authentication, and permission layers around it did not (as of November 2026).
Authentication and user management went with it, so apps had to move to another authentication service before the cutoff. The Rules and Roles system that controlled data access was deprecated alongside Device Sync. So was the App Services Wire Protocol, which was deprecated with the Realm SDKs.
Community branches of the SDKs strip the Device Sync code out, so an app can keep Realm as a local store.
Beyond the sync-first services covered earlier, MongoDB’s migration page adds AWS AppSync, HiveMQ, Ably, Parse, and Cedalo, plus a custom build with a consulting partner.
HiveMQ, Ably, and Cedalo are messaging and pipeline products built around MQTT and pub/sub. They move data. They do not give a mobile app a local database.
Developers took the timeline hard. One forum poster described an app that cost hundreds of thousands of dollars to build, with cloud sync as its main feature, and called one year a short window for a rewrite.
MongoDB’s replies to similar questions were that apps with Device Sync already set up and running would stay available until the end-of-life date, but that new Device Sync apps could no longer be created. Both statements were true, and neither saved the rewrite.
How to limit lock-in
Keep sync behind a repository, so the network data source can be swapped without touching screens. Prefer sync against a server you can self-host or fork (Parse, for example, is an open source backend server), and keep an export path so data leaves the local store as plain records.
Treat any proprietary sync service as a dependency with an end date you do not control.
How do you secure a database on a mobile device?

Encrypt the data at rest and keep the encryption key in the platform keystore. Then enforce access rules on the server. Skip any of those and the other two do not cover the gap.
OWASP’s Mobile Application Security Verification Standard lists the storage failure patterns: sensitive data stored unencrypted, keys kept outside the platform keystore, data left in backups, and secrets hardcoded in the app package.
Those gaps are the usual opening list in any set of mobile app security best practices.
Encrypt the database file
SQLCipher adds transparent 256-bit AES full database encryption to SQLite and supports iOS and Android. The Community edition is open source with core functions only, and paid editions add a commercial license.
On iOS, Data Protection turns on automatically once the user sets a passcode, and files default to the “complete until first user authentication” level.
Zetetic’s SQLCipher page publishes no overhead percentage. Any overhead figure you see elsewhere is unverified, so measure on your own devices.
Apple’s stronger complete class discards its class key shortly after the device locks. A background sync that touches such a file while the phone is locked will fail.
Protect the key
Encrypting the file is pointless if the key sits next to it.
Android Keystore keeps key material out of the app process, so a compromised app can use its keys but cannot extract them. Keys can be bound to secure hardware, though only where the device supports the key’s algorithm and settings. StrongBox, available from Android 9, offers stronger isolation but is slower, so it suits apps at risk of physical tampering.
Even with hardware binding, an attacker who compromises the OS can still use the keys on that device. They cannot take them off it.
Enforce access rules on the server
Cloud Firestore
- Security Rules check every client request, and if any requested document path is denied, the whole request fails
- User-based and role-based access needs Firebase Authentication alongside the rules
- Server client libraries bypass the rules and authenticate through IAM instead
- An allow-all rule set lets anyone overwrite the entire database
Supabase
Row Level Security must be enabled on every table in an exposed schema. On existing projects, new tables in the public schema start with privileges granted to anon, authenticated, and service_role, and RLS is not on by default. Since May 30, 2026, new projects no longer expose new public tables to the Data API automatically, so each table needs an explicit grant.
Watch the policy syntax too. A policy with no to clause applies to public, which includes unauthenticated visitors.
In both products the client SDK is public code, so assume anyone can call the backend directly. The rules are the security.
Test them the way an attacker would, with direct calls that skip your app, as part of mobile app security testing.
How do mobile databases compare on speed, cost, and scale?
Local databases cost nothing per operation and scale with the device’s storage. Cloud backends bill per operation or per GB, and published speed claims lean heavily on vendor benchmarks.
Speed
The sources disagree, so treat any single ranking with care.
ObjectBox publishes open source benchmarks against Realm and Room, and its own post says there cannot be enough disclaimers on any performance benchmark. In its public app benchmark (10,000 objects, averaged over 10 runs on a Nexus 5X), ObjectBox posted the lowest create, update, and delete times. Room beat plain SQLite on those three, and batched SQLite closed most of the create gap.
An academic study (arXiv, 2018) found that plain SQLite had the best summed ranking across eight persistence frameworks, with Realm fifth, and traced Java Realm’s update cost partly to missing batch updates.
The tests differ in workload, batching, devices, and library versions. The study dates from 2018 and the app benchmark ran on a 2015 phone.
Batch your writes before you blame the database.
Cost
As of November 2026, the Cloud Firestore free quota is 50,000 document reads and 20,000 document writes per day. Supabase Free gives you a 500 MB database per project and pauses it after 1 week of inactivity, while Supabase Pro starts from $25 per month.
Firestore bills per document read (plus index entry reads), per document written or deleted, and per GiB stored. A screen that re-reads a long list on every open spends reads on every document in it.
The Supabase pause is the one to watch. A free-tier backend that sleeps after a quiet week breaks a side project that users expect to be always on.
Scale

Scale limits show up as data model limits before they show up as hosting limits. Firestore caps a document at 1 MiB (1,048,576 bytes), so large blobs and unbounded arrays belong in separate documents or in file storage.
Firestore’s best-practices page warns that sequential document IDs such as Customer1, Customer2 create hotspots that hurt latency, and it limits write rates on collections whose indexed field increases sequentially, such as a timestamp.
That is where app scaling turns into a data modeling problem instead of a server-sizing one.
How do you test a database choice before committing?

Prototype two candidates against your real offline scenarios, your real data volume, and a low-end device before you commit. A two-week spike costs less than a mid-project database swap.
- List the offline scenarios: what must read, create, edit, and delete with no network.
- Set the data shape and volume: records per user, the largest single record, and monthly growth.
- Build a two-week spike with two candidates.
- Edit the same record on two devices while offline, reconnect, and check which version survives.
- Benchmark with your own dataset on the slowest device you support.
- Upgrade from the oldest app version still in use to the newest, and check that the data arrives intact.
- Put the winner behind a repository layer, so replacing it later does not touch the screens.
Treat the spike as software prototyping: build it fast and throw it away once you decide.
Schema migration: what an upgrade costs and what breaks
DZone’s mobile database refcard notes that a release with an updated data schema can force expensive migrations at app launch, adding start-up cost and degrading the user experience.
Room’s automated migrations need the exported schema for both versions and fail if exportSchema is false. Deleting or renaming a table or column raises a compile-time error until you add an AutoMigrationSpec, and with no migration path at all, Room throws an IllegalStateException.
fallbackToDestructiveMigration avoids the crash, but it permanently deletes all data in the affected tables.
Room’s MigrationTestHelper verifies the schema after each migration, and running every migration from version 1 catches differences between fresh and upgraded databases. Run those tests on every release as part of regression testing.
Mobile App Database FAQ
Can a mobile app connect directly to a MySQL or PostgreSQL server?

Not safely. Stock MySQL and PostgreSQL ship no mobile SDK, so the app reaches them through an API that holds the credentials.
Supabase is the exception on Postgres. Every project is a full Postgres database, and Row Level Security must be enabled on every table in an exposed schema.
Is Firebase a database or a platform?
Mostly a platform. It bundles two databases, Cloud Firestore and Realtime Database. Flutter’s guide recommends Firestore over Realtime Database for new apps, unless you only need low-latency sync for small, frequent state.
How is Room different from SQLite?
Room sits on top of SQLite. The engine is SQLite, and Room is a library over it.
Room adds compile-time verification of SQL queries and streamlined migration paths, while your data still lives in a SQLite file on the device.
Which database is easiest for a beginner?
A local one. On iOS 17 or later that means SwiftData, while Android developers can use Room and Flutter developers Drift.
There is no server, no sync, and no billing to set up. Add Cloud Firestore later, when users need to share data.
Can one app use two databases at once?
Yes, and many production apps run exactly that split: a local database for the working copy and a cloud backend for the shared copy.
Keep one source of truth per record type. Two writable copies of the same record is how sync conflicts start.
When Is Switching a Mobile App Database Worth It?

Switching after launch pays off when the current database has an end date, or when its data model has stopped fitting the app. A sync layer that cannot be replaced counts as well. Speed differences alone do not justify the move.
Swap the sync layer first. The storage engine comes second, behind a tested upgrade path, and the cloud backend goes last.
Realm’s local database outlived its sync service, and Android’s offline-first guide keeps the network data source behind a repository. Together they show that the sync layer is the part built to be replaced, so it carries the least risk.
The cost is a dual-running period, with writes reaching both sync layers until every installed app version has updated.
Position verified November 2026. A vendor end-of-life notice moves the sync swap to the front of the queue, and the rest of the tech stack for app development decides which replacements stay available.
- Is Notepad++ Safe? Official Download, Updates, CVEs - November 29, 2026
- How to Evaluate an AI Code Reviewer on Your Own Pull Requests - November 29, 2026
- Outsourcing Medical Device Software Securely - November 28, 2026



