Data Browser

Last updated last month

ObjectBox - Data Browser

The ObjectBox data browser (short: object browser) allows you to view the entities and schema of your database inside a regular web browser. You can also download entities in JSON format. The object browser runs directly on your device or on your development machine. Behind the scenes this works by bundling a simple HTTP browser into ObjectBox when building your app. If triggered, it will then provide a basic web interface to the data and schema in your box store.

ObjectBox - Data Brower

Setup

We strongly recommend to use the object browser only for debug builds. Make sure that you apply the “io.objectbox” plugin after the dependencies block:

dependencies {
debugImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
releaseImplementation "io.objectbox:objectbox-android:$objectboxVersion"
}
// ObjectBox browser dependencies must be set before applying the plugin so it does not add objectbox-android
// (would result in two conflicting versions, e.g. "Duplicate files copied in APK lib/armeabi-v7a/libobjectbox.so").
apply plugin: 'io.objectbox'

Ensure that the INTERNET permission is present in the Android manifest as the object browser binds to a local port:

<uses-permission android:name="android.permission.INTERNET" />

After creating your box store, start the object browser. Typically in your Application onCreate method:

boxStore = MyObjectBox.builder().androidContext(App.this).build();
if (BuildConfig.DEBUG) {
boolean started = new AndroidObjectBrowser(boxStore).start(this);
Log.i("ObjectBrowser", "Started: " + started);
}

Browse data on your device

When the app starts an object browser notification should appear. Tapping it will launch a service to keep the app alive and opens the data browser interface in the web browser on the device.

To stop the service keeping your app alive, tap the ‘Stop’ button in the notification.

Browse data on your dev machine

To open the browser website on your development machine check the Logcat output when launching the app. It will print the port and the ADB command needed to forward the port to your machine:

I/ObjectBrowser: ObjectBrowser started: http://localhost:8090/index.html
I/ObjectBrowser: Command to forward ObjectBrowser to connected host: adb forward tcp:8090 tcp:8090

If available, port 8090 is used by default. So in most cases just run this command on your dev machine:

adb forward tcp:8090 tcp:8090

Once the port is forwarded you can open a browser and go to http://localhost:8090/index.html.

Download entities

When viewing entities tap the download button at the very bottom. This will download entities formatted as JSON.

Download entities