Class java.util.Map has generic type parameters, please use GenericTypeIndicator instead

后端 未结 6 1250
既然无缘
既然无缘 2020-11-29 09:11

I am using firebase to retrieve data from database n use

Map map = dataSnapshot.getValue(Map.class);

to get values, but it

6条回答
  •  一生所求
    2020-11-29 09:57

    To introduce the GenericTypeIndicator, you can change this line:

    Map map = dataSnapshot.getValue(Map.class);
    

    in to this:

    GenericTypeIndicator> genericTypeIndicator = new GenericTypeIndicator>() {};
    Map map = dataSnapshot.getValue(genericTypeIndicator );
    

    This should work well in your case. Please give it a try and let me know.

提交回复
热议问题