I have VisitingCardPOJO
form table. I want update single entry say where no=3
VisitingCardPOJO.java
public class VisitingCardPOJO extends RealmObject {
@PrimaryKey private int no;
private String name;
private String address;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
I found the solution as and It worked
public void updateNewCard(Realm realm, VisitingCardPOJO card) {
realm.beginTransaction();
VisitingCardPOJO toEdit = realm.where(VisitingCardPOJO.class)
.equalTo("no", card.getNo()).findFirst();
toEdit.setName(card.getName());
toEdit.setAddress(card.getAddress());
realm.commitTransaction();
}
see demo for Realm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With