Android Firebase如何获取推送值的键

Ant*_*oco -2 android firebase firebase-realtime-database

如何获得按键(用蓝色笔突出显示的按键)?我想获取该值,以便更改subjectName子级的值。

1个

Bro*_*onx 5

如果要在写操作之前知道按键值是多少,则必须执行以下操作:

//get the push key value
String key = mDatabase.child("posts").push().getKey();

//then you can write in that node in this way
mDatabase.child("posts").child(key).setValue(yourValue)
Run Code Online (Sandbox Code Playgroud)