我想检查节点是否已创建。我刚刚在下面实现了Toast,但没有任何敬酒。
注意:firebase DataBase现在为Total null
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Toast.makeText(RegisterActivity.this, dataSnapshot.getKey() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
Toast.makeText(RegisterActivity.this, databaseError.toString() + "", Toast.LENGTH_SHORT).show();
}
});
其次是我试过的代码,但没有运气
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
reference.child("device_id");
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Toast.makeText(RegisterActivity.this, dataSnapshot.getKey() + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
Toast.makeText(RegisterActivity.this, databaseError.toString() + "", Toast.LENGTH_SHORT).show();
}
});
答案 0 :(得分:0)
更改此行代码:
${= ${Str} == ABC =}
使用:
reference.addListenerForSingleValueEvent(new ValueEventListener() {