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

Time:08-05

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.

CodePudding user response:

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