my solution, although not really if it is very good, was not dependent on Application, because an android app can only have an Application class declared in the manifest of the main app where the library is run. therefore I decided to create a class with the singleton pattern and from there call when necessary to DaoSession. I'll leave the code for you if it's useful, or if you can improve it.
This is the class:
public class DaoHelper {
private static volatile DaoHelper daoInstance;
private DaoSession daoSession;
private DaoHelper(Context context){
//Prevent form the reflection api
if(daoInstance!=null){
throw new RuntimeException("Use getInstance() method to get the single instance of this class.");
}else{
CustomDaoMaster.OpenHelper helper = new CustomDaoMaster.OpenHelper(context,
"db",null);
SQLiteDatabase db = helper.getWritableDatabase();
CustomDaoMaster daoMaster = new CustomDaoMaster(db);
daoSession = daoMaster.newSession();
}
}
public static DaoHelper getInstance(Context context){
//Double check locking pattern
if(daoInstance==null){
synchronized (DaoHelper.class){//Check for the second time.
//if there is no instance available... create new one
if(daoInstance==null)daoInstance = new DaoHelper(context);
}
}
return daoInstance;
}
public DaoSession getDaoSession(){
return daoSession;
}
and this is the way to use it:
DaoSession daoSession = DaoHelper.getInstance(context).getDaoSession();