Skip to content Skip to sidebar Skip to footer

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

data structure

Solution 2:

Here is code snapshot how i done

     recyclerView= (RecyclerView) findViewById(R.id.my_Recylerivew_);

        recyclerView.setLayoutManager(newLinearLayoutManager(this));

        FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        //DataBase raffinalFirebaseDatabasedatabase= FirebaseDatabase.getInstance();
        myRef = database.getReference();
        myRef.keepSynced(true);


        FirebaseRecyclerAdapter<Student,myViewHolader> adapter = newFirebaseRecyclerAdapter<Student, myViewHolader>(


                Student.class,android.R.layout.two_line_list_item,myViewHolader.class,myRef
        ) {
            @OverrideprotectedvoidpopulateViewHolder(myViewHolader viewHolder, Student model, int position) {


                viewHolder.myTextView.setText(model.getName());

            }
        };

recyclerView.setAdapter(adapter);

and my viewholder.java

publicstaticclassmyViewHoladerextendsRecyclerView.ViewHolder{

        public TextView myTextView;


        publicmyViewHolader(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"