I have some difficulties in updating an object at a bucket (key).
At the time of persistence, I push()
a list of objects (in this case, Trip) to a node.
Later, I retrieved it, and make an update (in this case, updating the bid info) when a button is clicked. I can't seem to find an easy way to do that, unless when I had pushed the trip before, I had to manually call getkey()
and then update the auto-generated uid to the object Trip itself. Any idea to get it done easily? thanks
mFirebaseAdapter = new FirebaseRecyclerAdapter<Trip,
TripViewHolder>(
Trip.class,
R.layout.item_message,
TripViewHolder.class,
mFirebaseDatabaseReference.child(CHILD_TRIPS)) {
@Override
protected void populateViewHolder(TripViewHolder viewHolder, final Trip model, int position) {
viewHolder.btnTakeNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bid bidAtReserved = new Bid(mDriverCarInfo, model, MY_PRICE);
mFirebaseDatabaseReference.child(CHILD_TRIPS)
//here, I want to update the bidding to this trip, but
//I can't get the uid of the trip, unless I had
//manually recorded at the time of pushing the trip
.child(model.getUid())
.child("bids").push().setValue(bidAtReserved);
}
});
}
};