greendao sessions with multiprocesses on android

不打扰是莪最后的温柔 提交于 2019-12-11 05:30:29

问题


I am working on a large project that involves many different applications communicating to the same database at the same time.

I have been changing our system over to using greendao to see if it would give us performance improvements over Android ContentProvider.


The question:

Every time that an application needs to communicate with the database, i have it getting a new DaoSession and then performing the action. I am never re-using any DaoSessions. Would it be better if each application had their own DaoSession?

Keep in mind that i am concerned about concurrency between all these apps reading/writing from the database at the same time.

  1. Currently i am doing this each time an insert needs to happen:

this.daoMaster.newSession().getMyDao().insert(myDao);

  1. Or should i be getting a reference to a DaoSession from somewhere else and doing this:

this.daoSession().getMyDao().insert(myDao);


回答1:


Don't recreate it, keep the DaoSession in application scope.

PS.: I'd be interested if you succeeded to improve your performance using greenDAO.



来源:https://stackoverflow.com/questions/15797018/greendao-sessions-with-multiprocesses-on-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!