database.DatabaseException: Can't convert object of type java.lang.String to type

后端 未结 2 1922
面向向阳花
面向向阳花 2020-12-06 09:03

My Problem

      08-10 04:23:28.820 21501-21501/my.org.medicare.medicareapp E/AndroidRuntime: FATAL EXCEPTION: main                                                   


        
2条回答
  •  孤街浪徒
    2020-12-06 09:17

    Your fetchData function already receives DataSnapshot as a child-node, but even here you still loop through the children which will effectively be looping through individual keys (name, contact, centre). You should simply call getValue on DataSnaphot without looping:

    private void fetchData(DataSnapshot dataSnapshot)
        {
            spacecrafts.clear();        
            protest spacecraft=dataSnapshot.getValue(protest.class);
            spacecrafts.add(spacecraft);        
        }
    

    I hope this helps.

提交回复
热议问题