Question

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);

Was it helpful?

Solution

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top