-
Notifications
You must be signed in to change notification settings - Fork 0
genericDAO
ali ghahremani edited this page Mar 14, 2019
·
2 revisions
use sqlite in simple way
step1: implements Model on your class that you wants to CRUD
public class User implements Model {
private String id;
public String name;
public String lName;
public int age;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
}step2: make a DAO class (recomended)
public class UserDao extends GenericDAO<User> {
public UserDao(Context context) {
super(context, User.class, "UsersTable", true);
}
}step3: use :)
UserDao db = new UserDao(this);
db.Drop();
db.Insert(user);
db.Update(user);
db.Remove(user.getId())
List<User> users = db.getAll();
List<User> alis = db.getWithCondition(new KeyValDb.Condition() {
@Override
public boolean IsConditionTrue(Object object) {
return ((User) object).name.equals("ali");
}
});