Where does greenDAO generator code go?

277 Views Asked by At

I'm investigating greenDAO for an Android version of one of our iOS apps that heavily uses CoreData functionality.

I'm confused on how to start though. I've seen the DaoGeneratorExample code, but I'm not confident on how that relates to my project.

Let's assume my project is called MyApp. Do I need to create a SECOND Android project called MyAppDaoGenerator which I just run to generate java files and put them in the MyApp directories?

Or is the schema generation supposed to exist within the MyApp code?

2

There are 2 best solutions below

2
On BEST ANSWER

The easy way to have all the code (the generator and the generated one) in one single project is to have all the generator code in a module as a Java library .

In this github project you have an already created module that you could import and modify to suit your needs. In the project README there's also a nice tutorial on how to run the generator code.

If you want to do it from scratch, this answer looks like a good point to start, but I always used the import module method.

2
On

In the greenDao Generator Class you will have to specify the directory to your main project where you want the generated files to be stored.

See a tutorial i wrote about greenDao full implementation with android integrating-greenDao-into-your-android-application