通过LitePal保存集合到本地(可增删改查)
compile 'org.litepal.android:core:1.3.2'
第一步建立
Connector.getDatabase();
保存:
Book book = new Book();
book.setName("The Da Vinci Code");
book.setAuthor("Dan Brown");
book.setPages(454);
book.setPrice(16.96);
book.setPress("Unknow");
book.save();
更新:
Book book = new Book();
book.setPrice(14.95);
book.setPress("Anchor");
book.updateAll("name = ? and author = ?", "The Lost Symbol", "Dan Brown");
删除:
DataSupport.deleteAll(Book.class, "price < ?", "15");
查询:
List books = DataSupport.findAll(Book.class);
2021-04-10 00:24:39
4.94MB
本地保存
1