Tung Mai Le Tung Mai Le - 8 months ago 24
Android Question

In firebase, how do I retrieve the uid that was automatically created when pushing?

how do I retrieve the uid (automatically created) as the id of the object itself, so later I can find the object and update its child properties (if any). Thanks.

For example:

// I know this process will create a uid for the newly pushed object, and I want to get the uid of the bucket.


Try this:

ref = mFirebaseDatabaseReference.child(OBJ_CHILD).push();

... // create hashmap to push (friendlyObject)

String uid = ref.getKey();

see more here - https://www.firebase.com/docs/android/guide/saving-data.html under
Getting the Unique ID Generated by push()