本文介绍了在境界Update语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 VisitingCardPOJO 表格的表我想更新单个条目说得清否= 3

 公共类VisitingCardPOJO扩展RealmObject {

   @PrimaryKey私人诠释无;
    私人字符串名称;
    私人字符串地址;

    公众诠释getNo(){
        没有返回;
    }

    公共无效setNo(INT无){
        this.no =无;
    }

    公共字符串的getName(){
        返回名称;
    }

    公共无效setname可以(字符串名称){
        this.name =名称;
    }

    公共字符串的getAddress(){
        退货地址;
    }

    公共无效setAddress(字符串地址){
        this.address =地址;
    }
}
 

解决方案

我找到了解决方案,它的工作

 公共无效updateNewCard(境境界,VisitingCardPOJO卡){
        VisitingCardPOJO toEdit = realm.where(VisitingCardPOJO.class)
                。.equalTo(否,card.getNo())的FindFirst();
        realm.beginTransaction();
        toEdit.setName(card.getName());
        toEdit.setAddress(card.getAddress());
        realm.commitTransaction();
    }
 

见境界演示

I have VisitingCardPOJO form table I want update single entry say where no=3

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) {
        VisitingCardPOJO toEdit = realm.where(VisitingCardPOJO.class)
                .equalTo("no", card.getNo()).findFirst();
        realm.beginTransaction();
        toEdit.setName(card.getName());
        toEdit.setAddress(card.getAddress());
        realm.commitTransaction();
    }

see demo for Realm

这篇关于在境界Update语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 13:44