Reputation: 81
How do i retrieve the key of a newly inserted object in firebase.. The Object was inserted using android using setValue()
firebaseDatabaseRef.push().setValue(user);
Where user is a java object..
I need to key to update an attribute in my object.
The firebase ref is already pointing at the node in which the children are added.
Upvotes: 0
Views: 1800
Reputation: 3436
To get the key:
String Key = firebaseDatabaseRef.push().getKey();
then you can set value:
firebaseDatabaseRef.child(Key).setValue(YourValue);
Upvotes: 4