java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.database
<p>I am trying to retrieve data into a RecyclerView from Firebase Database but am experiencing this error  java.lang.NullPointerException: Attempt to invoke virtual method. <code>'com.google.firebase.database.DatabaseReference com.google.firebase.database.DatabaseReference.child(java.lang.String)' on a null object reference</code></p>

<p>Below is my main activity class .</p>

<pre><code>    package oerrride.we.huzykamz.testingappfirebase;

    import android.app.Dialog;
    import android.content.Context;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.support.v7.widget.LinearLayoutManager;
    import android.support.v7.widget.RecyclerView;
    import android.view.View;
    import android.widget.Button;

    import com.google.android.gms.common.GoogleApiAvailability;
    import com.google.android.gms.tasks.Task;
    import com.google.firebase.database.ChildEventListener;
    import com.google.firebase.database.DataSnapshot;
    import com.google.firebase.database.DatabaseError;
    import com.google.firebase.database.DatabaseReference;
    import com.google.firebase.database.FirebaseDatabase;
    import com.google.firebase.database.ValueEventListener;

    import java.util.ArrayList;
    import java.util.List;


    public class MainActivity extends AppCompatActivity {

        private Button but;
        private DatabaseReference mRef;
        private MyAdapter adapter;
        public RecyclerView recyclerView;

        public List&lt;ModelClass&gt; movies_;
        public Context c;
        private LinearLayoutManager linearLayoutManager;

        private DatabaseReference mMovieRef =mRef.child("Name");

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            movies_ = new ArrayList&lt;ModelClass&gt;();

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

            linearLayoutManager = new LinearLayoutManager(this);
            recyclerView.setLayoutManager(linearLayoutManager);
            recyclerView.setHasFixedSize(true);
            mRef =  FirebaseDatabase.getInstance().getReferenceFromUrl("xxxxxxxxxxxxxxxxxxxxxx");


            mRef.addChildEventListener(new ChildEventListener() {
                @Override
                public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                    LoadData(dataSnapshot);
                }

                @Override
                public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                    LoadData(dataSnapshot);
                }

                @Override
                public void onChildRemoved(DataSnapshot dataSnapshot) {

                }

                @Override
                public void onChildMoved(DataSnapshot dataSnapshot, String s) {

                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });




        }



        public void LoadData (DataSnapshot dataSnapshot){
            for(DataSnapshot singlesnapshot :dataSnapshot.getChildren()){
              String taskTitle =singlesnapshot.getValue(String.class);

                movies_.add(new ModelClass(taskTitle));

                adapter = new MyAdapter(MainActivity.this, movies_);
                recyclerView.setAdapter(adapter);



            }

        }

    }


And this is my Adapter class .







public class MyAdapter extends RecyclerView.Adapter&lt;MyViewHolder&gt; {




 protected   Context c;
    List&lt;ModelClass&gt; movies;

public MyAdapter(Context c, List&lt;ModelClass&gt; movies) {
    this.c = c;
    this.movies = movies;
}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_activity,parent,false);
    MyViewHolder holder = new MyViewHolder(v);
    return holder;
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {

    holder.name.setText(movies.get(position).getName());
  // PicassoClient.downloadImage(c,movies.get(position).getUrl(),holder.img);

}

@Override
public int getItemCount() {
    return movies.size();
}
</code></pre>

<p>}</p>

<p>Below is my Console of Firebase database</p>

<p><a href="http://i.stack.imgur.com/I4M0K.png" rel="nofollow">Firebase Console data am trying to fetch</a></p>