androidsugarorm

How can update record in Sugar ORM?


I'm new to Sugar ORM and want to update simple one record of the table

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();


This does not update the table with the record.


Solution

  • In sugar ORM your class PagingSelected is extention of SugarRecord, so you can use base methods.

    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));