答案 0 :(得分:1)
getRef()
不接受文档中的参数:
public DatabaseReference getRef ()
用于获取对此快照的源位置的引用。
返回:
与此快照来自的位置对应的DatabaseReference
你可以这样做:
使用名为productList
final String product_key=productList.get(position).getKey();
答案 1 :(得分:1)
Inside onBindViewHolder
method you can get the key using the following line of code:
String product_key = getItem(position);
getRef() is used to obtain a reference to the source location for the snapshot. So you can only use this method on a snapshot object. It returns a DatabaseReference
and takes no argument. Below an example:
DatabaseReference ref = snapshot.child("users").getRef();