You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks to Johan Poirier, you may inject your OrmLite DAOs with the @OrmLiteDao annotation.
Note : The minimum version required of ORMLite is 4.21
The @OrmLiteDao has one mandatory attribute :
helper should hold the class of your database helper (which should extend com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper)
Note : For getting and releasing the helper, we use the OpenHelperManager class, which cannot handle two different helpers at the same time. So if you are using multiple database helpers, be careful with OrmLiteDao annotations.
Usage:
@EActivitypublicclassMyActivityextendsActivity {
// UserDao is a Dao<User, Long>@OrmLiteDao(helper = DatabaseHelper.class)
UserDaouserDao;
@OrmLiteDao(helper = DatabaseHelper.class)
Dao<Car, Long> carDao;
}
Method based injection
Since AndroidAnnotations 4.0.0
@EActivitypublicclassMyActivityextendsActivity {
@OrmLiteDao(helper = DatabaseHelper.class)
voidsetUserDao(UserDaouserDao){
// do something with userDao
}
}
In earlier versions of AndroidAnnotations @OrmLiteDao had model as second mandatory attribute. It was required to point to the model class that the DAO relates to. It should match the type of the first generic parameter of your Dao
RuntimeExceptionDao
Since AndroidAnnotations 3.0
Before 3.0, only subclasses of Dao could be annotated with @OrmLiteDao.
Now we also handle subclasses of RuntimeExceptionDao
Since AndroidAnnotations 3.3
It's now possible to inject custom classes that extend from RuntimeExceptionDao. The class requires a constructor that takes a Dao for the Model that should be used.