Connection to failed firebase

1

Hello everyone, my problem is that I want to bring data from a firebase database with server java but it does not bring them back, it returns null.

This is my https://github.com/Miguel546/firebasemaven code if you can help me please it's supposed to return a json but it does not return anything. According to the database should return

{
    {"Lucas": "Luis"}, 
    {"Miguel": "Miguelito"}
} 

sisalud-be5b4
 nombres
 Lucas: 
"Luis"
 Miguel: 
"Miguelito"

but it does not return anything to me

https://sisalud-be5b4.firebaseio.com/nombres
hola porque no entra
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------

This is the part that does not work does not enter the code.

ref.addListenerForSingleValueEvent(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot ds) {
        System.out.println(ds.getKey());
        System.out.println(ds.getValue());
        System.out.println("hola");  
    }
    @Override
    public void onCancelled(DatabaseError de) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
});
    
asked by Luis Miguel Casas 31.03.2017 в 20:20
source

1 answer

0

Assuming that the ref is correct and that you get only one element, what matters is that the line

System.out.println(ds.getValue());

really should be something like

System.out.println(ds.getValue(String.class));

That is, when using getValue you must include the type of data that we bring.

    
answered by 08.05.2017 в 01:45