Com.google.firebase.database.DatabaseException: Failed To Convert A Value Of Type Java.lang.String To Double
OK, so this code used to work until my friend decided to change the Firebase structure and now it doesn't work. Even now, if I change the code Here's the error code : E/AndroidRunt
Solution 1:
my data in my firebase was a string instead of a double for the locationLong and locationLat as evident as the 2 quotation marks in the data.
So the moral of the story here is check your variables
Thanks for all the helps in the comment section
Solution 2:
Here is code snapshot how i done
recyclerView= (RecyclerView) findViewById(R.id.my_Recylerivew_);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
//DataBase raf
final FirebaseDatabase database = FirebaseDatabase.getInstance();
myRef = database.getReference();
myRef.keepSynced(true);
FirebaseRecyclerAdapter<Student,myViewHolader> adapter = new FirebaseRecyclerAdapter<Student, myViewHolader>(
Student.class,android.R.layout.two_line_list_item,myViewHolader.class,myRef
) {
@Override
protected void populateViewHolder(myViewHolader viewHolder, Student model, int position) {
viewHolder.myTextView.setText(model.getName());
}
};
recyclerView.setAdapter(adapter);
and my viewholder.java
public static class myViewHolader extends RecyclerView.ViewHolder{
public TextView myTextView;
public myViewHolader(View itemView) {
super(itemView);
myTextView= (TextView) itemView.findViewById(android.R.id.text1);
}
}
if you want to get full code here is link to my github and if you want video tutorial here is link to my channel
Post a Comment for "Com.google.firebase.database.DatabaseException: Failed To Convert A Value Of Type Java.lang.String To Double"