Skip to main content

Local Database Handling

GreenDAO Local Database

Introduction

This part of the document outlines the implementation of a local database within an ZM application utilizing GreenDAO, a robust Object-Relational Mapping (ORM) library.

Features

  • Lightweight and efficient.
  • Auto-generates database schema and object mappings.
  • Supports complex queries with ease.
  • Easy integration with Android projects.

Configuration Steps

  1. Add Dependencies
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' // Plugin version
}
}

apply plugin: 'org.greenrobot.greendao'

dependencies {
api 'org.greenrobot:greendao:3.3.0'
}

  1. Sync the Project

Sync your project to apply the dependencies.

Generate DAO Classess

Configure GreenDAO

Add configuration to your build.gradle file to specify where the generated files

greendao {
schemaVersion 1 // Database schema version
daoPackage 'com.example.app.dao' // Package for DAO classes
targetGenDir 'src/main/java' // Directory for generated files
}