GreenDao数据库在App里声明

public class MyApp extends Application {
    private static MyApp instance;
    private DaoMaster.DevOpenHelper daohelp;
    private DaoMaster daoMaster;
    private  DaoSession daoSession;
    private SQLiteDatabase database;
    @Override
    public void onCreate() {
        super.onCreate();
        ImageLoaderConfiguration imageLoaderConfiguration=new ImageLoaderConfiguration.Builder(this).build();
        ImageLoader.getInstance().init(imageLoaderConfiguration);
        instance=this;
        getData();
    }

    public static MyApp getInstance(){
        return instance;
    }

    private void getData() {
        daohelp=new DaoMaster.DevOpenHelper(this,"Preson1",null);
         database = daohelp.getWritableDatabase();
        daoMaster=new DaoMaster(database);
        daoSession = daoMaster.newSession();
    }
    public DaoSession getDaoSession(){
        return daoSession;
    }
    public  SQLiteDatabase getdatabase(){
        return database;
    }
}

你可能感兴趣的:(GreenDao数据库在App里声明)