realm-java
Realm is a mobile database: a replacement for SQLite & ORMs
A mobile database for Android that stores data as objects your Java code reads and writes directly, with optional real-time sync across devices. Now deprecated, new projects should use the Realm Kotlin SDK instead.
Realm is a mobile database built to run directly on Android phones, tablets, and wearables. Unlike traditional databases that store data in tables and require a translation layer to work with your code, Realm stores data as objects that your app can read and write directly. The goal was to make storing and retrieving data on a mobile device feel simpler and faster than the alternatives.
The Java version of Realm targets Android exclusively. You define your data as plain Java classes, and Realm handles the storage. There is no separate query language to learn: you filter and sort data using regular Java code. The library also handles thread safety automatically, so you do not have to write extra locking code when reading data on one thread while writing on another. Encryption and relationships between data objects are built in.
One notable feature documented in the README is Device Sync, which keeps data synchronized in real time across multiple devices and a cloud backend. This means that if a user updates something on one phone, other devices see the change without any custom server code on your part. The sync backend was provided by MongoDB Atlas.
It is worth knowing upfront that MongoDB announced the deprecation of the Atlas Device Sync service and all Realm SDKs in September 2024. This Java SDK is no longer actively developed. For new Android projects, the README directs developers to the Realm Kotlin SDK instead, which supports both Android and Kotlin Multiplatform. The Java SDK remains available for teams maintaining existing apps, but starting a new project on it is not recommended.
If you still need to build from source, the README lists a fairly involved setup: JDK 8, Android Studio, specific Android SDK build tools, CMake, the NDK, and several environment variables. The Gradle build command assembles all the necessary components, though the README notes the full build can take an hour or more.
Where it fits
- Store and query app data on Android devices as plain Java objects without writing SQL.
- Sync data in real time across multiple Android devices without writing custom server sync code.
- Maintain an existing Android app that already uses the Realm Java SDK.
- Add built-in encryption to locally stored app data on Android.