Answers to Java, Kotlin, and Android specific ObjectBox questions

Does ObjectBox support Kotlin? RxJava?

ObjectBox comes with full Kotlin support including data classes. And yes, it supports RxJava and reactive queries without RxJava.

Does ObjectBox support object relations?

Yes. ObjectBox comes with strong relation support and offers features like “eager loading” for optimal performance.

Does ObjectBox support multi-module projects? Can entities be spread across modules?

The ObjectBox plugin only looks for entities in the current module, it does not search library modules. However, you can have a separate database (MyObjectBox file) for each module. Just make sure to pass different database names when building your BoxStore.

Is ObjectBox a “zero copy” database? Are properties fetched lazily?

It depends. Internally and in the C API, ObjectBox does zero-copy reads. Java objects require a single copy only. However, copying data is only a minor factor in overall performance. In ObjectBox, objects are POJOs (plain objects), and all properties will be properly initialized. Thus, there is no run time penalty for accessing properties and values do not change in unexpected ways when the database updates.

Are there any threading constrictions?

No. The objects you get from ObjectBox are POJOs (plain objects). You are safe to pass them around in threads.

On which platforms does ObjectBox run?

Android (4.0 and above on armeabi-v7a, arm64-v8a, x86 and x86_64), Linux (64 bit), Windows (64 bit), macOS, iOS. ObjectBox comes in flavors for Java, Go, C, and Swift.

Can I use ObjectBox on the desktop/server?

Yes, you can ObjectBox on the desktop/server side. Contact us for details if you are interested in running ObjectBox in client/server mode or containerized!

Can I use ObjectBox on smart IoT devices?

Generally speaking: Yes. You can run the ObjectBox database on any IoT device that runs Linux. We also offer Go and C APIs.

How do I rename object properties or classes?

If you only do a rename on the language level, ObjectBox will by default remove the old and add a new entity/property. To do a rename, you must specify the UID.

How much does ObjectBox add to my APK size?

The download size increases by around 1.6 MB by default as a library for each supported architecture is packaged. If you split your APK by ABI or use an App Bundle only around 0.5 MB.

Open your APK in Android Studio and have a look at the lib folder to see the raw file size and download size added.

The raw file (APK) size increases around 4.3 MB. This is because the library sets extractNativeLibs="false" in your AndroidManifest.xml as recommended by Google. This turns off compression but reduces the size of your app updates (on Android 6.0 or newer). Read this Android developers post for details. It also avoids issues that might occur when extracting the libraries.

If you rather have a smaller APK instead of smaller app updates you can override the flag in your AndroidManifest.xml:

// not recommended, increases app update size

More importantly, ObjectBox adds little to the APK method count since it’s mostly written in native code.

Can I ship my app with a pre-built database?

Yes. ObjectBox stores all data in a single database file. Thus, you just need to prepare a database file and copy it to the correct location on the first start of your app (before you touch ObjectBox’s API).

There is an experimental initialDbFile() method when building BoxStore. Let us know if this is useful!

The database file is called data.mdb and is typically located in a subdirectory called objectbox (or any name you passed to BoxStoreBuilder). On Android, the DB file is located inside the app’s files directory inside objectbox/objectbox/. Or objectbox/<yourname> if you assigned the custom name <yourname> using BoxStoreBuilder.

Answers to other questions

Questions not related to Java, Kotlin or Android are answered in the general ObjectBox FAQ.

If you believe to have found a bug or missing feature, please create an issue. https://github.com/objectbox/objectbox-java/issues

If you have a usage question regarding ObjectBox, please post on Stack Overflow. https://stackoverflow.com/questions/tagged/objectbox