i know this question has been asked before but my code is still not working after applying the patches. when i touch the fetch button it crashes and shows the error
java.lang.NullPointerException: Attempt to invoke virtual method 'androidx.recyclerview.widget.RecyclerView$Adapter androidx.recyclerview.widget.RecyclerView.getAdapter()' on a null object reference
at com.example.csitcms.myrecyclerviewActivity$1.onChildAdded(myrecyclerviewActivity.java:35)'
The last line of the code shows the error below:
public class myrecyclerviewActivity extends AppCompatActivity {
RecyclerView recyclerView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_recycler_view);
DatabaseReference databaseReference= FirebaseDatabase.getInstance().getReference();
databaseReference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
String filename= dataSnapshot.getKey();
String url= dataSnapshot.getValue(String.class);
((MyAdapter)recyclerView.getAdapter()).update(filename,url);
}