0
mFirebaseInstance.getReference("app_title").addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        Log.e(TAG, "App title updated");

        String appTitle = dataSnapshot.getValue(String.class);
        long s = dataSnapshot.child("daysOnWhichPresent").getValue(Long.class);

        // update toolbar title

        textGrid.setText(appTitle);
    }

    @Override
    public void onCancelled(DatabaseError error) {
        // Failed to read value
        Log.e(TAG, "Failed to read app title value.", error.toException());
    }
});

java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference at omari.hamza.storyviewdemo.MainActivity$15.onDataChange(MainActivity.java:673) at com.google.firebase.database.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:75) at com.google.firebase.database.core.view.DataEvent.fire(DataEvent.java:63) at com.google.firebase.database.core.view.EventRaiser$1.run(EventRaiser.java:55)

fantaghirocco
  • 4,345
  • 6
  • 34
  • 46

1 Answers1

0

It seems dataSnapshot.child("daysOnWhichPresent") does not exist and you are getting NullPointerException when trying to get its value

Amin Mousavi
  • 895
  • 6
  • 18