我希望Id为整数,不想使用Push.For 例如:
{
"chats": {
"1": {
"title": "Historical Tech Pioneers",
"messages": {
"1": { "sender": "ghopper", "message": "Relay malfunction found. Cause: moth." },
"2": { ... },
}
},
"2": { ... }
}
}
答案 0 :(得分:0)
push()
方法生成随机密钥,请尝试此
mRef.child("chats").child(your_id).setValue();
答案 1 :(得分:0)
试试这个:
define globe int i=1;
++i;
databaseReference.child("chats").child(i).setValue();