Android documentation generator

Android-documentation-generator-featured.jpg

Introduction

greenDAO is definitely an object/relational mapping (ORM) tool for Android. It provides an item oriented interface towards the relational database SQLite. ORM tools like greenDAO do many repetitive tasks for you personally and provide an easy interface for your data.
DAO Code Generation Project

To be able to use greenDAO inside your Android project (usually an Eclipse project), you have to produce a second project, the &ldquogenerator project&rdquo. Its task would be to generate code specific for your project domain. The generator project is definitely an normal Java (not Android!) project. Make certain the greenDAO generator library (greenDAO-generator.jar) and also the Freemarker library (freemarker.jar) have been in its classpath. Create an executable Java class, model your organizations and trigger the code generation. For particulars, take a look in the modelling documentation.
Core Classes

When you produced any project specific code, you can begin using greenDAO inside your Android project. Be sure to range from the greenDAO core library (greenDAO.jar) inside your Android project.

The next core courses are the fundamental interface to greenDAO:

DaoMaster: The access point for implementing greenDAO. DaoMaster supports the database object (SQLiteDatabase) and handles DAO classes (not objects) for any specific schema. It’s static techniques to produce the tables or drop them. Its inner classes OpenHelper and DevOpenHelper are SQLiteOpenHelper implementations that induce the schema within the SQLite database.

DaoSession: Handles all available DAO objects for any specific schema, which you’ll acquire using among the getter techniques. DaoSession provides several generic persistence techniques like place, load, update, refresh and remove for organizations. Lastly, a DaoSession objects also monitors a name scope. For additional particulars, take a look in the session documentation.

DAOs: Data access objects (DAOs) continues and queries for organizations. For every entity, greenDAO creates a DAO. It’s more persistence techniques compared to DaoSession, for instance: count, loadAll, and insertInTx.

Organizations: Persistable objects. Usually, organizations are produced (you don’t have to), and therefore are objects representing a database row using standard Java qualities (just like a POJO or perhaps a JavaBean).
Core Initialization

The next code example demonstrates the very first steps to initialize the database and also the core greenDAO classes:
assistant = new DaoMaster.DevOpenHelper(this, “notes-db”, null)
db = assistant.getWritableDatabase()
daoMaster = new DaoMaster(db)
daoSession = daoMaster.newSession()
noteDao = daoSession.getNoteDao()

The example assumes getting a &ldquoNote&rdquo entity. Using its DAO (noteDao object), we are able to call the persistence operation with this specific entity.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>