Greendao remove from db and session

I am using greendao for an android project and want to know how to properly delete and create objects from db and from the session cache. I am currently doing the following to remove from db:

ChatDao chatDao = daoSession.getChatDao(); chatDao.queryBuilder().buildDelete().executeDeleteWithoutDetachingEntities(); 

However, since the method name and documentation indicate that this can leave obsolete objects in the session cache, how can I delete objects there too?

+7
source share
2 answers

To clear cached objects in DaoSession, use this call:

 DaoSession.clear(); 

It will clear all objects in your session identification area.

+8
source

As described by Anatoly, you can use DaoSession.clear (). However, it will clear all objects from the session. If you want to avoid this, you need to execute a regular query and delete the result objects (for example, using deleteInTx).

+3
source

All Articles