public class IApplication extends Application {
public static IGetDataService service;
public static DaoSession session;
@Override
public void onCreate() {
super.onCreate();
//1.初始化retrofit
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://www.zhaoapi.cn")
.addConverterFactory(GsonConverterFactory.create())
.build();
//访问网络数据的对象
service = retrofit.create(IGetDataService.class);
//2.初始化Fresco
Fresco.initialize(this);
//3.初始化greendao
DaoMaster.DevOpenHelper openHelper = new DaoMaster.DevOpenHelper(this, "tablename");
Database database = openHelper.getWritableDb();
//操作数据库的对象
session = new DaoMaster(database).newSession();
}
}
别忘了在清单文件中引用