问题描述
我试图解决如何从我的DatabaseReference中获取值,但是这样做给了我完整的地址,当我想把它放在一个TextView中
是参考:
public static DatabaseReference getUsernameRef(String email){
return FirebaseDatabase.getInstance()。getReference nom_usuarios);
这些是我想要拯救的值:
我试试这个:
$ b $ pre $ mPosti.setUsername(FirebaseUtils.getUsernameRef(FirebaseUtils.getCurrentUser()。getEmail())。toString()) ;
但是不是接收值,我得到数据库的地址。 $ b $ div class =h2_lin>解决方案
);
database.addListenerForSingleValueEvent(new ValueEventListener(){
@Override
public void onDataChange(DataSnapshot dataSnapshot){
//这里您将获得datasnapshot
中的值( DataSnapshot dataSnapshot:dataSnapshot.getChildren()){
list.add(dataSnapshot.getValue());
}
}
@Override
public void onCancelled(DatabaseError databaseError){
}
});
I am trying to solve how to get a value from my DatabaseReference, but doing so gives me the full address when I want to put it in a TextView
This is the reference:
public static DatabaseReference getUsernameRef(String email){
return FirebaseDatabase.getInstance().getReference("nom_usuarios");
These are the values that I want to rescue:
i tried this:
mPosti.setUsername(FirebaseUtils.getUsernameRef(FirebaseUtils.getCurrentUser().getEmail()).toString());
But instead of receiving the value, I get the address of the database.
DatabaseReference database = FirebaseDatabase.getInstance().getReference().child("nom_usuaios").getRef();
database.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// here you will the value in datasnapshot
for (DataSnapshot dataSnapshot : dataSnapshot.getChildren()) {
list.add(dataSnapshot.getValue());
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
这篇关于如何从我的Firebase获得一些价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!