0

how to use if condition i (i want to retrieve values those name = banana or like that what is the condition according to my code is used)How can we retrieve values from database by the condition, suppose we want to retrieve values have name is equal to this then show name else

ProductsRef = FirebaseDatabase.getInstance().getReference().child("Obesity Gain");
            ProductsRef.orderByChild("Items").addChildEventListener(new ChildEventListener() {
                @Override
                public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
                    Products products=dataSnapshot.getValue(Products.class);
                    if(products.pname=="Makhan"){
                        onStart();
                    }
                    else {
                        Intent intent = new Intent(Hyperproductdisplay.this, Hyperproductdetails.class);
    
                    }





    FirebaseRecyclerAdapter<Products, ProductViewHolder> adapter =
                    new FirebaseRecyclerAdapter<Products, ProductViewHolder>(options) {
                        @Override
                        protected void onBindViewHolder(@NonNull ProductViewHolder holder, int position, @NonNull final Products model)
                        {
    
                            if(model.pname=="Makhan"){
                                holder.txtProductName.setText(model.getPname());
                                holder.txtProductDescription.setText(model.getDescription());
                                holder.txtProductPrice.setText("Calories = " + model.getPrice() + "$");
                                Picasso.get().load(model.getImage()).into(holder.imageView);
    
                                holder.imageView.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        Intent intent = new Intent(Hyperproductdisplay.this, Hyperproductdetails.class);
                                        intent.putExtra("pid",model.getPid());
                                        startActivity(intent);
    
                                    }
                                });
                            }

how to use if condition i  (i want to retrieve values those name = banana or like that what is the condition according to my code is used)How can we retrieve values from database by the condition, suppose we want to retrieve values have name is equal to this then show name else 
Peter Haddad
  • 78,874
  • 25
  • 140
  • 134

0 Answers0