Exchange

Copy values from a Child to another Child - Firebase Android Studio

 


private void confirmOrder() {

FirebaseDatabase.getInstance().getReference().child("Hospital").child("Users").child(uid).child("Cart")
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {

FirebaseDatabase.getInstance().getReference().child("Hospital").child("Users").child(uid).child("Order")
.setValue(snapshot.getValue()).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(ProfileActivity.this, "Order Confirmed", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(ProfileActivity.this, "Failed!", Toast.LENGTH_SHORT).show();
}
}
});
}

@Override
public void onCancelled(@NonNull DatabaseError error) {

}
});

}



Post a Comment

0 Comments