How can I remove rows from GreenDao based on a condition?

I want to delete rows from a table based on a condition. as

"remove from table, where Name =" Value "

here i am using greenDAO database.

+3


source to share


1 answer


1 Check the documentation .

2 Create a DeleteQuery for your table

3 Execute it

4 Clear the session so that all caches also lose deleted objects.



final DeleteQuery<Table> tableDeleteQuery = daoSession.queryBuilder(Table.class)
.where(TableDao.Properties.Name.eq("Value"))
.buildDelete();
tableDeleteQuery.executeDeleteWithoutDetachingEntities();
daoSession.clear();

      

If you need to execute the request multiple times, save the request object to avoid re-creating it.

Btw greenDAO is an ORM, not a database (here it is SQLite).

+5


source







All Articles