1.倒入jar包,创建实体类,user
public class User {
//这里需要注意的是User对象必须有id属性,或者有通过@ID注解的属性
private int id;
private String name ;
private String pwd;
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getPwd() { return pwd; }
public void setPwd(String pwd) { this.pwd = pwd; }
}
FinalDb db=FinalDb.create(this);
db.deleteAll(User.class);
for (int i=1;i<6;i++){
User user=new User();
user.setName(i+"");
user.setPwd(i*10+"");
db.save(user); //增
}
db.deleteByWhere(User.class,"name like 4"); //删
List<User> userList=db.findAll(User.class); //查
for (int i=0;i<userList.size();i++){
result_tv.append(userList.get(i).getName()+">>"+userList.get(i).getPwd()+"\n");
}