title: How to fix Unboxing may produce nullPointer Exception with firebase?
body: <p><a href="https://i.stack.imgur.com/qDUNV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qDUNV.png" alt="enter image description here"></a>No matter which user I am logged in as the "points" variable is always returned as 0. The same code works on separate activities and I cannot see what is different. When I hover over the datasnapshot is says that is may produce null pointer exception but it also says this on the other activities that work. I have spent ages trying out figure this out. Thanks.</p>
  
  <pre><code>        databaseUsers =FirebaseDatabase.getInstance().getReference("Users");
          final FirebaseAuth firebaseAuth;
          firebaseAuth = FirebaseAuth.getInstance();
          user = firebaseAuth.getCurrentUser();
          databaseUsers.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              points = dataSnapshot.child(user.getUid()).child("points").getValue(int.class);
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
      //Getting Total Points from Firebase Database
      databaseUsers.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              totalpoints = dataSnapshot.child(user.getUid()).child("totalpoints").getValue(int.class);
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  </code></pre>