无法在路径string()子级中传递null参数 [英] Can't pass null argument in path string() child

查看:40
本文介绍了无法在路径string()子级中传递null参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

databaseReference = FirebaseDatabase.getInstance().getReference("FcmgSupplyDetails").child(State).child(City).child(Sub).child(DistributorID).child(RandomId);
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
        UpdateProductModel updateDishModel = dataSnapshot.getValue(UpdateProductModel.class);
        Foodname.setText(updateDishModel.getProducts());
        String qua = "<b>" + "Quantity: " + "</b>" + updateDishModel.getQuantity();
        FoodQuantity.setText(Html.fromHtml(qua));
        String ss = "<b>" + "Description: " + "</b>" + updateDishModel.getDescription();
        FoodDescription.setText(Html.fromHtml(ss));
        String pri = "<b>" + "Price: ₹ " + "</b>" + updateDishModel.getPrice();
        FoodPrice.setText(Html.fromHtml(pri));
        Glide.with(OrderProductActivity.this).load(updateDishModel.getImageURL()).into(imageView);

推荐答案

您不能将 null 作为您的数据库路径,因为null表示无意义或无处不在,因此这就是它给您带来麻烦的原因.错误,因为如果将任何子名称作为 null 传递,则路径将无效.

You cannot have a null as your database path, because null means nothing or nowhere so that is the reason it is giving you the error because the path will be invalid if any of the child names is passed as null.

如果您指向数据库引用添加一个空检查,然后仅执行它,则总是更好,因为如果任何键(子)名称作为空传递,那么它将不起作用.

It's always better if you are pointing to database reference to add a null check and then only execute it because if any of the key(child) name passed as null then it will not work.

这篇关于无法在路径string()子级中传递null参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆