У меня есть эта ошибка, и я не знаю, как ее исправить
Причина: java.lang.NullPointerException: попытка вызвать виртуальный метод 'com.google.firebase.database.ChildEventListener com.google.firebase.database.Query.addChildEventListener (com.google.firebase.database.ChildEventListener) 'для ссылки на пустой объект
enter code here
RecyclerView mRecyclerView;
FirebaseDatabase mFirebaseDatabase;
DatabaseReference mRef;
//ActionBar
ActionBar actionBar = getSupportActionBar();
//set title
actionBar.setTitle("List");
// RecyclerView mRecyclerView = findViewById (R.id.recyclerView);mRecyclerView.setHasFixedSize (true);
//layout linear
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//send query to firebase
mFirebaseDatabase = FirebaseDatabase.getInstance();
mRef = mFirebaseDatabase.getReference("Data");
}
//load data into recycler view onStart
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<Model, ViewHolder> firebaseRecyclerAdapter =
new FirebaseRecyclerAdapter<Model, ViewHolder>(
Model.class,
R.layout.row,
ViewHolder.class,
mRef
) {
@Override
protected void populateViewHolder(ViewHolder viewHolder, Model model, int i) {
viewHolder.setDetails(getApplicationContext(), model.getTitle(), model.getDescription(), model.getImage());
}
};
//adapter ro recycler
mRecyclerView.setAdapter(firebaseRecyclerAdapter);
}
}