Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

mercedes-benz/MBSDK-RealmKit-Android

Repository files navigation

MBRealmKit

License Platform Version

Requirements

  • Minimum Android SDK: MBRealmKit requires a minimum API level of 21.
  • Compile Android SDK: MBRealmKit requires you to compile against minimum API level 27.

Intended Usage

This module contains convenient APIs for the usage of Realm.

Create a database

  1. Create your model class
open class RealmUser : RealmObject() {

    @PrimaryKey
    var id: String = ""

    var name: String? = null
}
  1. Define a module A module can be any class, it just needs the @RealmModule annotation.
@RealmModule(classes = [RealmUser::class])
class RealmModule
  1. Initialize Realm with your application context
MBRealmKit.apply {
    // Create a plain realm.
    createRealmInstance(
        "id_my_plain_realm",
        RealmServiceConfig.Builder(appContext, 1L, RealmModule())
            .build())
    // Create an encrypted realm.
    createRealmInstance(
        "id_my_encrypted_realm",
        RealmServiceConfig.Builder(appContext, 1L, RealmModule())
            .encrypt()
            .build())
}
  1. Access to the created realm You can access your realms with the id you provided in createRealmInstance():
// Get realm.
val realm = MBRealmKit.realm(REALM_ID)

// 
val users = realm.where<RealmUser>().findAll()

Installation

Add the following maven url to your project build.gradle:

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://pkgs.dev.azure.com/daimler-ris/sdk/_packaging/release/maven/v1'
        }
    }
}

Add to your app's build.gradle:

implementation "com.daimler.mm:MBRealmKit:$mb_realm_kit_version"

Contributing

We welcome any contributions. If you want to contribute to this project, please read the contributing guide.

Code of Conduct

Please read our Code of Conduct as it is our base for interaction.

License

This project is licensed under the MIT LICENSE.

Provider Information

Please visit https://mbition.io/en/home/index.html for information on the provider.

Notice: Before you use the program in productive use, please take all necessary precautions, e.g. testing and verifying the program with regard to your specific use. The program was tested solely for our own use cases, which might differ from yours.

About

Mercedes-Benz Mobile SDK - RealmKit module for Android

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published