How to edit the existing SQL table column values using GreenDao?

943 Views Asked by At

I'm using greenDao for my Android project and I did not get any official documentation on how to update SQLite table using greenDao. I found some .update() method there to edit, but looks like it's not recommended.

1

There are 1 best solutions below

0
On

Here's some code updating an entity. You don't have to modify the generated class.

db = helper.getWritableDatabase();
DaoMaster daoMaster = new DaoMaster(db);
DaoSession daoSession = daoMaster.newSession();
ExampleDao exampleDao = daoSession.getExampleDao();
Example example = exampleDao.load(exampleKey);

/* Make your changes in the object */

exampleDao.update(example);

If you need more documentation you can have a look here and here.