Onyx Database with Android

Android NoSQL Database
Integrate Onyx Database with Android
This tutorial will guide you through how to integrate Onyx Database within an Android project. Create a database within Android and use it within a mobile application.

The example application illustrates how to create an Android application with an in-memory database. The Android application is a simple master detail application for displaying cookbook recipes. It contains the entire Gradle configuration and dependencies. Starting in Onyx 2.1.0, it can fully support Java 1.7, 1.8, and Kotlin mixed JVM language targets.

You can download the code for this example here: OnyxDevTools/onyx-database-samples/onyx-android-example.

Configure using Gradle

  1. Define the gradle build file to use jackOptions
    Notes:
    Onyx is written in Kotlin and geared towards using Kotlin. It can also use Java 8 lambdas.
    This example uses the latest build tools 27. It requires > 26
    Source target and comparability are set to Java 1.8.
  2. Add Onyx as a maven dependency.

    Add maven central as a dependency source and add the latest Onyx as a dependency.

    Notes:
    The onyx-android dependency is deprecated and no longer needed since Jack Options is deprecated.

Start Using Onyx NoSQL

  1. Define an entity
  2. Create a Persistence Manager Factory

    In this example we are using an cache in memory database. Alternatively you can connect to a remote or embedded database instance.

    Notes:
    If you are connecting to a remote database you must include permissions within the AndroidManifest.xml
    Android requires network communication to occur on a background thread. If you are using a remote database, execute the Persistence Manager and Persistence Manager Factory API within a background thread.
  3. Save an entity

    Upon executing your application, Onyx has automatically created an embedded database. This is a simple example on how to get started with Android. Other tutorials also contain information that apply to building out graph data models and interacting with the Persistence Manager API.

  4. Spring Configuration