I've been attempting to get acquainted with the GreenDao
Android ORM library. I've been following along with Green Robot's examples but have gotten stuck. Whenever I get an instance of one of my daos, UserDao
, I don't have any sort of queryBuilder()
method associated with the dao object.
import package.DaoMaster;
import package.DaoMaster.DevOpenHelper;
import package.DaoSession;
import package.UserDao;
public class DatabaseHelper {
private SQLiteDatabase db;
private DaoMaster daoMaster;
private DaoSession daoSession;
public DatabaseHelper(Context context) {
DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, "db", null);
this.db = helper.getWritableDatabase();
this.daoMaster = new DaoMaster(db);
this.daoSession = this.daoMaster.newSession();
// attempting to retrieve the queryBuilder instance from a user dao....
// however, no queryBuilder method exists
this.daoSession.getUserDao().queryBuilder();
}
}
What am I missing guys? I'm using the greendao-generator
artifact, versioned at 1.3.1
.
Finally figured this out. First, I'm using Android Studio 0.8.9
, which is using Gradle 2.1
.
In the build.gradle
file in the project's app
folder, I added compile( 'de.greenrobot:greendao:1.3.7')
to its dependencies
section. It looks something like this:
dependencies {
// ...
compile 'de.greenrobot:greendao:1.3.7'
// ...
}
From then on, the queryBuilder
method was available for all my daos
.