How to use GreenDao in android studio?

Here you will learn, how to integrate GreenDao with android studio. GreenDao is used for accessing local sql database into your android application. We will be creating a log app, that saves user text in the database.Lets get started. If you have any confusions, please feel free to download the entire project.

Donwload

STEPS:

PART1 : Setting Up GREENDAO

  1. Create an android project.
  2. Click File >New > New Module. Select Java Library and click Next.
    Greendao
  3. Now we have to add the following Gradle Dependencies.In build.gradle of Module:app, insert

    2
    In the build.gradle of  Module:greendao-generator, insert

    3
    Make sure, you sync your project.
    4
  4. Now in the MainGenerator.java, we will define the database structure.
  5. Run MainGenerator.java .5
  6. After running this, you will observe a newly created folder ie db in the Main Project Folder.
    6

PART2 : Integrating it with Android Project

  1. Set the activity_main.xml layout.
  2. In MainActivity.java

  3. Before Running the App, Make sure you have changed your configuration.
    7
  4. Now Run it.

PART 3 – VIEW THE SQL DB

  1. Open Command Prompt.
  2. Enter the following commands.
    8
  3. Opening the db file in SQLite3
    9
  4. Using SQLite3
    10

PART 4 – EXTRAS

  1. Structure (Core Classes) of GREENDAO
    Core-Classes-150