Data Browser

The ObjectBox data 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. Either 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.

Setup

Use the object browser artifact, which includes the data browser, when building a debug build. Make sure that you apply the objectbox plugin after the dependencies block.

Add the INTERNET permission to your manifest as the object browser binds to a local port:

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

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:

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

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.

Next steps

 

Spread the love