ObjectBox database setup in mobile app

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
ObjectBox database setup in mobile app
Medium
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1050
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Setting up ObjectBox Database in Mobile Application

ObjectBox positions itself as the fastest embedded database for mobile devices. The company's benchmarks show 10x advantage over Room/SQLite on write operations. In practice, the gap depends on access patterns, but ObjectBox is indeed faster on mass object insertions due to its native C++ engine without SQL parsing.

When ObjectBox Makes Sense

ObjectBox is an object database, not relational. No JOIN, no GROUP BY, no aggregate functions in the traditional SQL sense. If your application works with object graphs (entities with relationships) rather than analytical queries, ObjectBox wins. For IoT applications, trackers, game saves, catalogs with filtering — it's well-suited.

Connection 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
) {
    // ToMany relationships configured via RelationInfo
    val tags: ToMany<Tag> = toMany()
}

@Entity
data class Tag(
    @Id var id: Long = 0,
    var name: String = "",
    @Index var color: String = ""
)

@Id is mandatory Long for ObjectBox internal ID. This is not UUID and not 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 reactive subscription without extra code.

Queries via QueryBuilder

ObjectBox does not use string SQL. Queries use type-safe QueryBuilder with Properties — generated meta classes (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 JOIN — relationships via ToOne/ToMany. ObjectBox loads related objects lazily by default:

// ToMany loaded on first access
val taskTags = task.tags // lazy load, database access

ObjectBox Sync

Like Realm, ObjectBox offers a commercial synchronization server — ObjectBox Sync. Bidirectional sync, conflict resolution, delta updates. This is a separate product with licensing.

Typical Problems

ID is not UUID. ObjectBox assigns Long IDs automatically — they are unique only locally. For server synchronization, you need a separate UUID field with @Index.

Codegen on each build. The plugin generates MyObjectBox.java and _ classes. If the schema changed but gradle cache wasn't cleared, the compiler complains about mismatch. ./gradlew clean fixes it.

Open BoxStore — one per application. Attempting to open a second BoxStore on the same file throws an exception. Singleton via Application class is mandatory.

ObjectBox setup, models, reactive queries for Android: 3–5 days. Cost calculated individually.