We often encounter a situation: an Android app stutters when doing bulk data inserts — writing 1000 objects via Room takes 15 seconds. The client loses users due to lag. ObjectBox solves this: native C++ implementation without SQL parsing delivers up to 10x speedup on write operations. In our practice, we integrated ObjectBox into an IoT tracker that saved 500 points every 5 minutes — write time dropped from 8 to 0.7 seconds. Development time savings: up to 2 weeks per project thanks to automatic codegen and no DAOs. Additionally, the object model reduces code volume by 30–40%, directly lowering development and maintenance costs.
We configure ObjectBox end-to-end, including models, reactive queries, and synchronization. We evaluate your project in one day — contact us to get started.
Why ObjectBox is faster than SQLite?
ObjectBox is an object database, not relational. No JOINs, no GROUP BY — but for working with object graphs (entities with relations) that's not needed. Benchmarks from ObjectBox show a 10x advantage over Room/SQLite on writes. In real projects, the gap depends on patterns: bulk inserts — 3–10x win, reads by ID — roughly equal. For IoT apps, trackers, game saves, filterable catalogs, ObjectBox is ideal. Development savings: up to 40% compared to traditional solutions.
How to set up ObjectBox in 3–5 days?
The setup process includes several steps:
- Data schema analysis: identify entities and relations.
- Entity design with relations (ToOne, ToMany).
- Integration of BoxStore into the Application class.
- Implementation of reactive queries via DataObserver.
- Performance testing: measure write/read speed.
- Deployment to app stores.
Below is a typical stack and code.
Connecting and Models
// build.gradle (app)
plugins {
id("io.objectbox")
}
dependencies {
implementation("io.objectbox:objectbox-kotlin:3.8.0")
}
@Entity
data class Task(
@Id var id: Long = 0,
var title: String = "",
var description: String = "",
var priority: Int = 0,
var dueDate: Long = 0,
var isCompleted: Boolean = false
) {
val tags: ToMany<Tag> = toMany()
}
@Entity
data class Tag(
@Id var id: Long = 0,
var name: String = "",
@Index var color: String = ""
)
@Id is a mandatory Long for internal ObjectBox ID. This is not a UUID or your business identifier — use a separate string field for server synchronization.
Initialization and BoxStore
// Application class
class MyApp : Application() {
companion object {
lateinit var boxStore: BoxStore
private set
}
override fun onCreate() {
super.onCreate()
boxStore = MyObjectBox.builder()
.androidContext(this)
.name("tasks-db")
.build()
}
}
// Usage in ViewModel
class TaskViewModel : ViewModel() {
private val taskBox: Box<Task> = MyApp.boxStore.boxFor(Task::class.java)
val tasks: LiveData<List<Task>> = liveData(Dispatchers.IO) {
val query = taskBox.query(Task_.isCompleted.equal(false))
.order(Task_.priority, QueryBuilder.DESCENDING)
.build()
emitSource(query.subscribe().toLiveData())
}
}
query.subscribe().toLiveData() — ObjectBox DataObserver automatically notifies when data in the box changes. This is a reactive subscription without extra code.
Queries via QueryBuilder
ObjectBox does not use string SQL. Queries via type-safe QueryBuilder with Properties — generated metaclasses (Task_, Tag_):
// Filtering with multiple conditions
val urgentTasks = taskBox.query(
Task_.isCompleted.equal(false)
.and(Task_.priority.greater(2))
.and(Task_.dueDate.less(System.currentTimeMillis() + 86_400_000L))
)
.order(Task_.dueDate)
.build()
.find()
// Full-text search — requires @Index(type = IndexType.VALUE) + FTS
val searchResults = taskBox.query(
Task_.title.contains("meeting", StringOrder.CASE_INSENSITIVE)
)
.build()
.find()
No JOINs — relations via ToOne/ToMany. ObjectBox loads related objects lazy by default:
// ToMany loads on first access
val taskTags = task.tags // lazy load, DB access
ObjectBox Sync
Note: like Realm, ObjectBox offers a commercial synchronization server — ObjectBox Sync. Bidirectional sync, conflict resolution, delta updates. This is a separate product with a licensing model. We integrate Sync into your app turnkey.
How does ObjectBox Sync work?
ObjectBox Sync uses delta synchronization: only changed objects are transmitted, not the entire database. Conflict resolution is configurable: you can choose "last writer wins", "local priority", or custom logic. To start, just set up a Sync server and specify the URL in the client.
Comparison of ObjectBox and Room
| Criteria |
ObjectBox |
Room/SQLite |
| Write speed (1000 objects) |
~0.5 sec |
~5–15 sec |
| Read speed by ID |
~0.1 ms |
~0.2 ms |
| Reactive queries |
DataObserver |
Flow/LiveData via DAO |
| Synchronization |
ObjectBox Sync (commercial) |
Firebase, manual |
| Typical setup time |
3–5 days |
5–10 days |
Common Issues and Solutions
| Problem |
Solution |
| ID not UUID |
ObjectBox auto-assigns Long IDs — they are only unique locally. For server sync, add a separate string field with @Index. |
| Codegen on every build |
The plugin generates MyObjectBox.java and _ classes. If schema changes but gradle cache is not cleared, the compiler complains about mismatch. ./gradlew clean solves it. |
| Only one BoxStore per app |
Attempting to open a second BoxStore on the same file throws an exception. Singleton via Application class is mandatory. |
Why ObjectBox suits IoT apps?
IoT devices generate streaming time-series data: coordinates, sensor readings, logs. ObjectBox handles bulk inserts without delays, and reactive subscriptions instantly update the UI. In the tracker we built, writing 500 points per minute caused no lag — unlike Room, where GC led to freezes. ObjectBox is also available for Flutter and React Native, simplifying cross-platform development.
What's included in the work
- Object model design with relations
- BoxStore setup, codegen, index optimization
- Reactive query implementation (LiveData/Flow)
- ObjectBox Sync integration (if needed)
- Performance testing (before/after benchmarks)
- Documentation on schema and access
- 30-day support after delivery
Order ObjectBox setup for your mobile app — we guarantee results. For over 5 years we've been doing mobile development and delivered 50+ projects on ObjectBox and alternatives. Get a free estimate — write to us!
How to Choose a Local Data Storage Solution (Room, Core Data, Realm, Isar)?
We've all seen the scenario: the app loses data when the network drops — and it's not just a bug, it's a failure of the use case. The user fills out a form, taps "Submit", gets a timeout, and loses everything. Or worse: data gets sent twice due to incorrect retry logic. A properly chosen and configured storage layer solves this problem once and for all. The wrong choice can cost teams months of rewriting code and up to 70% of time spent on synchronization. Our experience — 10+ years in mobile development, over 50 projects with offline storage — confirms: the storage choice determines 80% of future performance and synchronization issues.
In practice, storage selection is driven by two factors: data type and synchronization requirements, not library popularity.
Room (Android) — a wrapper over SQLite with compile-time verification of SQL queries. If a query is invalid, the build fails — better than a SQLiteException at runtime. Room integrates well with Kotlin Flow and LiveData, making reactive UI updates straightforward. The main challenge is schema migrations. @Database(version = N, exportSchema = true) with migration files in assets/databases/ is mandatory; otherwise, fallbackToDestructiveMigration() will simply delete the user's data on app update.
Core Data (iOS) — not a database, but an object graph management framework over SQLite (or XML, or in-memory). NSPersistentContainer with viewContext for reading on the main thread and newBackgroundContext() for writing is the basic setup. The trouble begins when a developer calls save() on viewContext from a background thread: EXC_BAD_ACCESS at a random moment, happens once a week, with almost nothing useful in the crash log. You must use performAndWait or perform for each context strictly on its own thread. Apple Core Data Programming Guide recommends this approach.
Realm wins where you need speed with large object sets and built-in reactivity through Results + observe(). Realm stores objects directly without ORM mapping, so reads require no deserialization. According to our measurements, Realm processes reads 2–3 times faster than Core Data for volumes over 10,000 objects. On Flutter, the Realm SDK (ex-MongoDB Realm) supports Device Sync — but that's a managed service with separate infrastructure.
Hive and Isar are Flutter-specific solutions. Hive is a key-value store, fast, simple, suitable for settings and caches. Isar is a full document-oriented database with indexes, written in Rust, compiled to native code. For Flutter apps with offline functionality, Isar is now preferred: built-in query builder with type-safe filters, transactions, watchObject/watchQuery for reactivity.
| Platform |
Solution |
Reactivity |
Synchronization |
| Android |
Room + Flow |
LiveData/Flow |
WorkManager |
| iOS |
Core Data |
NSFetchedResultsController |
CloudKit |
| Flutter |
Isar |
Streams |
Custom / Realm Sync |
| Cross-platform |
Realm |
RealmResults.observe |
Device Sync |
| Flutter (simple) |
Hive |
ValueListenable |
None |
Contact us for a free audit of your current storage and optimization recommendations — this will save you hundreds of development hours and up to 60% of server request traffic.
Why Is Offline Synchronization the Hardest Part?
Local storage itself is not complicated. The complexity lies in synchronizing with the server in the presence of conflicts.
The most common pattern is optimistic updates with rollback. The user edits a record, the UI reflects the change instantly, a background request goes to the server. If the server returns an error, we roll back the local state. Sounds simple. In practice: if the user has left the screen and returned before the rollback (which may take 3 seconds), the UX is broken. You need an explicit operation queue with states (PENDING, SYNCED, FAILED) in a separate table.
On Android, for background synchronization we use WorkManager with Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED). Don't forget setInputMerger(ArrayCreatingInputMerger::class) when batching tasks — otherwise, concurrent runs will overwrite data. A typical operation queue implementation:
class SyncWorker(context: Context, params: WorkerParameters) : CoroutineWorker(context, params) {
override suspend fun doWork(): Result {
val pendingOps = syncDao.getPendingOperations()
for (op in pendingOps) {
try {
apiClient.send(op.payload)
syncDao.markSynced(op.id)
} catch (e: Exception) {
syncDao.markFailed(op.id, e.message)
return Result.retry()
}
}
return Result.success()
}
}
On iOS, the equivalent is BGTaskScheduler with BGProcessingTaskRequest. iOS limitations on background execution time (~30 seconds for refresh tasks) mean that synchronization must be incremental: not "sync everything," but "sync the next N records, save the cursor."
Conflicts in multi-device scenarios are resolved with one of three approaches:
- Last-write-wins based on
updated_at (simplest, loses data on concurrent edits)
- Server-wins (client always accepts server version)
- Three-way merge (complex, requires a common ancestor — suitable for documents)
For most B2C apps, last-write-wins with a user-level time vector is sufficient, but for collaborative editing, a CRDTs approach is needed — then look at Automerge or Yjs with mobile bindings.
How We Build the Storage Layer
The repository pattern is not optional — it's mandatory. UserRepository doesn't know where the data comes from: Room, Realm, or network. The ViewModel calls repository.getUser(id), gets a Flow/Stream, and displays data. Caching logic resides inside the repository.
For Flutter, a typical architecture: Isar for persistence, Riverpod for state management, ConnectivityPlus for network status, and a custom SyncService with an operation queue. Riverpod's AsyncNotifier conveniently covers the logic of "show cache, update from network, show new data." Example repository with caching:
class UserRepository {
final Isar isar;
final ApiClient api;
Future<User> getUser(String id) async {
// try from local storage first
final cached = await isar.user.where().idEqualTo(id).findFirst();
if (cached != null) return cached;
// otherwise from network
final remote = await api.fetchUser(id);
// save locally
await isar.writeTxn(() => isar.user.put(remote));
return remote;
}
}
Another important topic is encryption. If the app stores medical data, payment cards, or corporate documents, SQLCipher (Android) and NSFileProtection (iOS) are not optional. Realm supports encryption natively via a 64-byte key that must be stored in Keychain/Keystore, not in SharedPreferences. Skimping on security can lead to data leaks with serious consequences.
What the Work Includes
We guarantee a transparent process and document each stage:
| Stage |
Result |
| Requirements audit |
Document analyzing data types, volumes, synchronization scenarios |
| Schema design |
ER diagram, migration files, conflict resolution plan |
| Repository layer development |
Code with unit tests (in-memory DB + network mocks) |
| Synchronization integration |
Operation queue, error handling, fallback logic |
| Profiling and optimization |
Report from Android Profiler / Core Data SQLDebug, recommendations |
| Deployment and documentation |
Deployment instructions, API description, repository access |
Want to avoid common mistakes when designing storage? Contact us — we'll help design a reliable local storage from scratch or improve an existing one.
Stages of Work
We start with a requirements audit: what data, what volume, is synchronization needed, are conflicts possible. At this stage, it becomes clear whether Core Data or an SQLite-based solution is needed, whether Realm Sync is required or simple REST polling will suffice.
Next, we design the schema with migrations in mind. Schemas change in any project — the question is not "will there be migrations," but "how painful will they be." We export the schema as JSON, store it in the repository, and write tests for each version's migration.
Development includes unit test coverage for the repository layer: network layer mocks, a real in-memory database for query testing. Before release, we profile queries using Android Profiler (Database Inspector tab) or Core Data debug flags (-com.apple.CoreData.SQLDebug 1).
The implementation timeline for a storage layer with basic offline synchronization ranges from 2 to 6 weeks, depending on schema complexity and conflict resolution requirements. Contact us to get a consultation on choosing the optimal stack and migrations.