如何在Sugar ORM中更新记录?

时间:2018-01-16 10:20:34

标签: android sugarorm

我是Sugar ORM的新手,想要更新表中的简单记录

List<PagingSelected> finds = (List<PagingSelected>) PagingSelected.findWithQuery(PagingSelected.class,"Select * from "+NamingHelper.toSQLNameDefault("PagingSelected")+" LIMIT 1"); 
                finds.get(0).setNext(true);
                finds.get(0).update();


这不会使用记录更新表。

1 个答案:

答案 0 :(得分:0)

在糖ORM中,您的PagingSelected类是SugarRecord的扩展,因此您可以使用基本方法。

List<PagingSelected> finds = (List<PagingSelected>) PagingSelected.findWithQuery(PagingSelected.class,"Select * from "+NamingHelper.toSQLNameDefault("PagingSelected")+" LIMIT 1"); 
finds.get(0).setNext(true);
PagingSelected.saveInTx(finds.get(0));