@Retention(value=CLASS) @Target(value={FIELD,METHOD,PARAMETER}) public @interface OrmLiteDao
Use it on fields of any enhanced class to injects an OrmLite Dao, configured with the provided mode and helper classes.
The helper paramter is mandatory and should hold the class of your database helper which should extend com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
Note: The minimum version required of ORMLite is 4.21
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.
Example :
@EActivity
public class MyActivity extends Activity {
// UserDao is a Dao<User, Long>
@OrmLiteDao(helper = DatabaseHelper.class)
UserDao userDao;
@OrmLiteDao(helper = DatabaseHelper.class)
Dao<Car, Long> carDao;
@OrmLiteDao(helper = DatabaseHelper.class)
void singleInjection2(UserDao userDao) {
// do stuff
}
void multiInjection(@OrmLiteDao(helper = DatabaseHelper.class) UserDao userDao, @OrmLiteDao(helper = DatabaseHelper.class) Dao<Car, Long> carDao;) {
// do stuff
}
}
public abstract Class<?> helper
Copyright © 2010–2018 simpligility technologies inc.. All rights reserved.