簡體   English   中英

在Firebase中,如何檢索推送時自動創建的uid?

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

如何檢索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.

嘗試這個:

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

... // create hashmap to push (friendlyObject)
ref.setValue(friendlyValue);

String uid = ref.getKey();

在此處查看更多信息-https: //www.firebase.com/docs/android/guide/saving-data.html
Getting the Unique ID Generated by push()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM