0

I am Devloping a app that fetches data from firebase database into a recycler view. But the data is not getting fetched.

This is the code:

else if (getArguments().getInt(ARG_SECTION_NUMBER) == 2) {
                rootView = inflater.inflate(R.layout.fragment_street_food, container, false);
                final String[] dateee = new String[1];
                myRef1 = FirebaseDatabase.getInstance().getReference().child("Video_Upload").child("Street");
                rView = (RecyclerView) rootView.findViewById(R.id.StreetRecyclerView);
                RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
                rView.setLayoutManager(layoutManager);
                FirebaseRecyclerAdapter<StreetDataFetcher, Street_food.StreetViewHolder> FBRA = new FirebaseRecyclerAdapter<StreetDataFetcher, Street_food.StreetViewHolder>(
                        StreetDataFetcher.class,
                        R.layout.card_recycler_view,
                        Street_food.StreetViewHolder.class,
                        myRef1
                ) {
                    @Override
                    protected void populateViewHolder( Street_food.StreetViewHolder viewHolder, StreetDataFetcher model, int position ) {
                        viewHolder.setTitle(model.getVideoName());
                        viewHolder.setShortDesc(model.getShort_Desc());
                        viewHolder.setUsername(model.getUserName());
                        //viewHolder.setDate(model.getDateTime());
                    }
                };

                rView.setAdapter(FBRA);
                return rootView;
            }

StreetViewHolder.class

class StreetViewHolder extends RecyclerView.ViewHolder
    {
        TextView Username;
        TextView datee;
        TextView Title;
        TextView ShortDesc;
        public StreetViewHolder( View itemView ) {
            super(itemView);
            Username=(TextView)itemView.findViewById(R.id.UsernameText);
            datee=(TextView)itemView.findViewById(R.id.date);
            Title=(TextView)itemView.findViewById(R.id.Title);
            ShortDesc=(TextView)itemView.findViewById(R.id.ShortDescription);
        }

        public void setTitle( String title ) {
            Title.setText(title);
        }


        public void setShortDesc( String shortDesc ) {
            ShortDesc.setText(shortDesc);
        }

        public void setUsername( String username ) {
            Username.setText(username);
        }


        public void setDate( String date ) {
            datee.setText(date);
        }
    }

StreetDataFetcher

public class StreetDataFetcher {

    String UserName, VideoName, VideoPath, Long_Desc, Short_Desc, DateTime;
    int Likes, Views;

    public StreetDataFetcher( String userName, String videoName, String videoPath, String long_Desc, String short_Desc, String dateTime, int likes, int views ) {
        UserName = userName;
        VideoName = videoName;
        VideoPath = videoPath;
        Long_Desc = long_Desc;
        Short_Desc = short_Desc;
        DateTime = dateTime;
        Likes = likes;
        Views = views;
    }

    public StreetDataFetcher() {
    }

    public String getUserName() {
        return UserName;
    }

    public void setUserName( String userName ) {
        UserName = userName;
    }

    public String getVideoName() {
        return VideoName;
    }

    public void setVideoName( String videoName ) {
        VideoName = videoName;
    }

    public String getVideoPath() {
        return VideoPath;
    }

    public void setVideoPath( String videoPath ) {
        VideoPath = videoPath;
    }

    public String getLong_Desc() {
        return Long_Desc;
    }

    public void setLong_Desc( String long_Desc ) {
        Long_Desc = long_Desc;
    }

    public String getShort_Desc() {
        return Short_Desc;
    }

    public void setShort_Desc( String short_Desc ) {
        Short_Desc = short_Desc;
    }

    public String getDateTime() {
        return DateTime;
    }

    public void setDateTime( String dateTime ) {
        DateTime = dateTime;
    }

    public int getLikes() {
        return Likes;
    }

    public void setLikes( int likes ) {
        Likes = likes;
    }

    public int getViews() {
        return Views;
    }

    public void setViews( int views ) {
        Views = views;
    }
}

My firebase structure is shown below:

this is the picture of firebase Database root

The Data is not fetching in recycler view and there is no error present as well.

cse
  • 4,066
  • 2
  • 20
  • 37
Mohit Gupta
  • 41
  • 1
  • 7
  • **[this](https://stackoverflow.com/questions/49383687/how-can-i-retrieve-data-from-firebase-to-my-adapter/49384849)** is how you can retrieve data from a Firebase Realtime database and display it in a `RecyclerView` using `FirebaseRecyclerAdapter`. – Alex Mamo May 15 '18 at 15:13
  • Try also to name your fields like this: `String userName, videoName, videoPath, longDesc, shortDesc, dateTime;` – Alex Mamo May 15 '18 at 15:14

0 Answers0