public class DaoManager {
private static DaoManager instance;
private static final String DATABASE_NAME = "xxxx.db";
private final DaoSession mDaoSession;
public synchronized static void create(Context context) {
if (instance != null) {
return;
}
instance = new DaoManager(context);
}
static DaoManager instance() {
if (instance == null) {
throw new RuntimeException("DaoManager not created");
}
return instance;
}
private DaoManager(Context context) {
DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context,DATABASE_NAME){
@Override
public void onUpgrade(Database db, int oldVersion, int newVersion) {
super.onUpgrade(db, oldVersion, newVersion);
}
};
mDaoSession = new DaoMaster(helper.getWritableDb()).newSession();
}
DaoSession getDaoSession(){
return mDaoSession;
}
}