为了账号安全,请及时绑定邮箱和手机立即绑定

com.google.firebase.database.DatabaseException:

com.google.firebase.database.DatabaseException:

一只甜甜圈 2023-05-10 14:24:28
按照 firebase 数据库的文档尝试将数据检索到对象以供使用时,我收到错误消息。这是我的对象模型public class Cart {    private String pid, pname, price, discount, quantity;    public Cart() {    }    public Cart(String pid, String pname, String price, String discount, String quantity) {        this.pid = pid;        this.pname = pname;        this.price = price;        this.discount = discount;        this.quantity = quantity;    }    public String getPid() {        return pid;    }    public void setPid(String pid) {        this.pid = pid;    }    public String getPname() {        return pname;    }    public void setPname(String pname) {        this.pname = pname;    }    public String getPrice() {        return price;    }    public void setPrice(String price) {        this.price = price;    }    public String getDiscount() {        return discount;    }    public void setDiscount(String discount) {        this.discount = discount;    }    public String getQuantity() {        return quantity;    }    public void setQuantity(String quantity) {        this.quantity = quantity;    }}最后,我得到错误的代码和行被注释掉了。
查看完整描述

1 回答

?
函数式编程

TA贡献1807条经验 获得超9个赞

和是您的 firebase 数据库中的值quantity,在您的类中它被声明为. 这是抛出错误。像下面这样声明类。discountLongCartStringCart


public class Cart {


    private String pid, pname, price;

    private Long discount, quantity;


    public Cart() {

    }


    public Cart(String pid, String pname, String price, Long discount, Long quantity) {

        this.pid = pid;

        this.pname = pname;

        this.price = price;

        this.discount = discount;

        this.quantity = quantity;

    }


    public String getPid() {

        return pid;

    }


    public void setPid(String pid) {

        this.pid = pid;

    }


    public String getPname() {

        return pname;

    }


    public void setPname(String pname) {

        this.pname = pname;

    }


    public String getPrice() {

        return price;

    }


    public void setPrice(String price) {

        this.price = price;

    }


    public Long getDiscount() {

        return discount;

    }


    public void setDiscount(Long discount) {

        this.discount = discount;

    }


    public Long getQuantity() {

        return quantity;

    }


    public void setQuantity(Long quantity) {

        this.quantity = quantity;

    }

}

希望能解决您的问题。


查看完整回答
反对 回复 2023-05-10
  • 1 回答
  • 0 关注
  • 115 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信