如何使用SugarORM获取特定记录的默认保存ID?

时间:2016-10-06 04:55:58

标签: android

嗨我已经在我的应用程序中为sql事务实现了糖orm。我想获取由特定记录的糖orm生成的默认id。请帮助我。任何帮助将不胜感激。谢谢提前。我正在使用下面的链接糖orm。

https://github.com/satyan/sugar

我正在使用以下代码获取特定记录的获取ID

List<Book> books = new ArrayList<>();
        books.add(new Book("Title here 1", "1st edition"));
        books.add(new Book("Title here 2", "2nd edition"));
        books.add(new Book("Title here 3", "3rd edition"));
        SugarRecord.saveInTx(books);

        //update
        Book book = Book.findById(Book.class,1);
        book.title = "john smith";
        book.save();

        List<Book> booksone = Book.findWithQuery(Book.class,"Select id from Book where title = ?","john smith");

0 个答案:

没有答案