如何检索uid(自动创建)作为对象本身的id,所以稍后我可以找到该对象并更新其子属性(如果有的话)。谢谢。
例如:
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.
答案 0 :(得分:2)
试试这个:
ref = mFirebaseDatabaseReference.child(OBJ_CHILD).push();
... // create hashmap to push (friendlyObject)
ref.setValue(friendlyValue);
String uid = ref.getKey();
在此处查看更多内容 - Getting the Unique ID Generated by push()