ObjectBox Introduction

ObjectBox is a mobile database that persists objects simple and super fast. It lets you avoid many repetitive tasks and offers a simple interface to your data.

Gradle plugin and code generation

In order to use ObjectBox in your Android project, you need to add its Gradle plugin and Android library:

Then model your entities and make your project, for example using “Build > Make Project” in Android Studio.

Core Classes

Once you have defined at least one entity and successfully built your project, you can start using ObjectBox in your Android project.

The following core classes are the essential interface to ObjectBox:

MyObjectBox: Generated based on your entity classes, MyObjectBox supplies a builder to set up a BoxStore for your app.

BoxStore: The entry point for using ObjectBox. BoxStore is your direct interface to the database and manages Boxes.

Box: A box persists and queries for entities. For each entity, there is a Box (supplied by BoxStore).

Entities: Use ObjectBox annotations to mark your object classes as persistable.

Core Initialization

Finally, the basic steps to initialize the core ObjectBox classes:

The example assumes a Note entity exists. With its Box ( notesBox object), we can call the persistence operation for this specific entity.

Have an app with greenDAO? DaoCompat is for you!

DaoCompat is an compatibility layer that gives you an greenDAO like API for ObjectBox. This makes switching simple. Have a look at the example. Docs will follow, contact us if you have any questions!

Further Docs

ObjectBox Documentation

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •