i want to delete rows from a table based on condition. like
"delete from Table where Name='Value'"
here i am using greenDAO database.
1 Check the documentation.
2 Create a DeleteQuery for your Table
3 Execute it
4 Clear the session so that all caches lose the deleted objects too.
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 query multiple times, save the query object to avoid re-instantiating it.
Btw greenDAO is an ORM, not a database (here it's SQLite).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With