greenDAO is an Android ORM library which offers an object oriented interface to work with date in SQLite. The library also provides advanced ORM features such as session cache, eager loading, and active entities. It is also claimed to insert, update and load data at rates of several thousand entities per second.
devteam83 introduces how to work with greenDAO in a series of 4 posts. It is the most detailed tutorial about greenDAO I’ve found.
This part introduces library setup, data model and DaoGenerator.
- All theory, dear friend, is grey – our Datamodel
- Creating the project
- Download Dependencies
- Adjusting project structure
- Insert the Libraries
- Adjusting the Build-Script of the Generator-Module
- Creating the Datamodel
- Generating Classes
Main objective of this part is to create a working RecyclerView with sample data. You will also know how to load data using greenDAO.
- Adding Libraries
- Adjusting the apps Build-file
- Create the main Activity
- Add RecyclerView
- Make RecyclerView work
The developer move greenDAO session to Application to actually make the app work. RecyclerView’s onClick event is implement so user can click on a RecyclerView’s item to see its detail in a new Activity.
- Moving session routines to Application
- New Activity
- Add onClick Event in RecyclerView
- Loading detail data
The last part of this tutorial covers how to add, edit and delete data.