Search code examples
androiddatabasesugarcrm

I am trying to save data in Sugar DB(V 1.5)


Is there any .saveAll() method which I can use to save all the instances of a list from an API at once instead of saving by .save() method by iterating through the list.


Solution

  • Look at the example below. Hope this will help.

    List<Book> books = new ArrayList<>();
    books.add(new Book("isbn123", "Title here", "2nd edition"))
    books.add(new Book("isbn456", "Title here 2", "3nd edition"))
    books.add(new Book("isbn789", "Title here 3", "4nd edition"))
    SugarRecord.saveInTx(books);