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:
mFirebaseDatabaseReference.child(OBJ_CHILD).push().setValue(friendlyObject);
// 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)
ref.setValue(friendlyValue);
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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.