如何在对象的arraylist上执行bulkInsert?
我有一个Book的arraylist,我想使用Content Provider的bulkInsert函数批量插入一个Books列表;
这是书的arraylist:
private ArrayList<Book> bookList;
here is my code where I try to do bulkinsert
// insert data into database
public void insertData() {
ContentValues bookValues = new ContentValues();
for(Book book: bookList){
bookValues = new ContentValues();
bookValues.put(BookContract.BookEntry.COLUMN_ID, Book.getBook_id());
bookValues.put(BookContract.BookEntry.COLUMN_TITLE, Book.getTitle());
bookValues.put(BookContract.BookEntry.COLUMN_OVERVIEW, Book.getDescription());
}
// Finally, insert Book data into the database.
getActivity().getContentResolver().insert(
BookContract.BookEntry.CONTENT_URI, bookValues
);
}