Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

greendao delete from db and session

I'm using greendao for a android project and wanted to know how to properly delete and object from the db and from the session cache. Currently I do the following to delete from the db:

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

However as the method name and documentation state this may leave stale objects in the session cache, how can I remove the objects from there too?

like image 255
marchinram Avatar asked Jul 09 '12 00:07

marchinram


1 Answers

In order to clear cached objects in your DaoSession use this call:

DaoSession.clear();

It will clear all objects in your session identity scope.

like image 123
Anatoliy Avatar answered Nov 02 '22 10:11

Anatoliy