title: Attempt to invoke virtual method 'Post.getPostimage()' on a null object reference
body: <pre><code> private void getPostImage(final ImageView imageView, String postid){
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference(&quot;posts&quot;).child(postid);
          reference.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  Post post = dataSnapshot.getValue(Post.class);
                Glide.with(mContext.getApplicationContext()).load(post.getPostimage()).into(imageView);
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) {
  
              }
          });
      }
  </code></pre>
  <p>I'm getting an error that points to this line:</p>
  <pre><code>Glide.with(mContext.getApplicationContext()).load(post.getPostimage()).into(imageView);
  </code></pre>
  <p>Here is the error:</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.taimoorsikander.myapplication, PID: 20194
      java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.taimoorsikander.myapplication.Model.Post.getPostimage()' on a null object reference
          at com.taimoorsikander.myapplication.Adapter.NotificationAdapter$3.onDataChange(NotificationAdapter.java:177)
          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)
          at android.os.Handler.handleCallback(Handler.java:938)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:246)
          at android.app.ActivityThread.main(ActivityThread.java:8633)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
  </code></pre>
  <p>I tried debugging the app to locate the null value, but everything seemed fine. There is no null value in this line. How can I fix this issue?</p>