explaingit

greenrobot/greendao

12,602JavaAudience · developerComplexity · 2/5Setup · moderate

TLDR

An Android database library (now unmaintained) that maps Java objects to SQLite rows so you can store and retrieve data without writing raw SQL, authors now recommend ObjectBox instead.

Mindmap

mindmap
  root((greenDAO))
    What it does
      Android ORM
      Java to SQLite
      No raw SQL needed
    Key features
      Code generation
      Query builder
      Table relationships
    Optional
      SQLCipher encryption
      Custom type mapping
    Setup
      Gradle plugin
      Auto-generated classes
    Status
      Unmaintained
      Move to ObjectBox
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Store and query Java objects in a local SQLite database on Android without writing any raw SQL.

USE CASE 2

Use the query builder with named constants to avoid typo bugs in field names at compile time.

USE CASE 3

Store data in an encrypted SQLite database on Android by enabling the SQLCipher integration.

USE CASE 4

Model relationships between database tables and perform chained join queries using greenDAO's API.

Tech stack

JavaAndroidSQLiteGradle

Getting it running

Difficulty · moderate Time to first run · 30min

Project is no longer actively maintained, new Android projects should use ObjectBox, the authors' replacement library.

In plain English

greenDAO is a library for Android that makes it easier to store and retrieve data in a SQLite database. Instead of writing raw SQL queries, you define your data as Java objects and the library handles converting them to and from database rows. This pattern is called an ORM (Object-Relational Mapper). The README prominently warns that this project is no longer actively maintained, and the authors now direct new users to ObjectBox, their newer database library. When it was actively developed, greenDAO's main selling points were its small size (under 150 kilobytes) and speed. It used code generation to create the database access classes at build time rather than using reflection at runtime, which the authors claimed made it one of the fastest ORMs available for Android. Setup involves adding a Gradle plugin to the project, and when the project builds, the plugin automatically generates helper classes for accessing each database table. The library includes a query builder that uses named constants instead of raw strings, which helps avoid typos in field names at compile time rather than discovering errors at runtime. It supports relationships between tables, including chained joins for more complex queries. Custom data types can be stored by mapping them to a supported column type, and there is optional support for SQLCipher if you need to store data in an encrypted database. greenDAO has been available since 2011 and was used in many Android apps over the years. Documentation and getting started guides are hosted on the greenrobot website. The same organization also produced EventBus (a message-passing library for Android) and Essentials (a set of general utility classes), both of which remain separate repositories.

Copy-paste prompts

Prompt 1
How do I add greenDAO to an Android project with Gradle and define a simple entity class that maps to a database table?
Prompt 2
How do I query all records from a greenDAO table where a specific field matches a value, using the query builder?
Prompt 3
How does greenDAO handle one-to-many relationships between two entities, show me an example with User and Order objects.
Prompt 4
How do I enable SQLCipher encryption in a greenDAO Android app so the local database is password-protected?
Prompt 5
greenDAO says it is no longer maintained, how do I migrate my existing greenDAO database to ObjectBox?
Open on GitHub → Explain another repo

← greenrobot on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.