title: DataSnapShot Object's value returning null on getvalue(Boolean.class)
body: <p>I'm doing a realtime tracking application from a tutorial online, Here i'm setting the presence system using firebase. But it's crashing with:</p>
  
  <p><strong>/java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference</strong></p>
  
  <p>I don't understand what's wrong the guy who coded this has it working perfectly. </p>
  
  <blockquote>
    <p>The exception is happening at this line :<strong>if(dataSnapshot.getValue(Boolean.class)){</strong></p>
  </blockquote>
  
  <p>When i log this on screen the datasnapshot object has a key but no value</p>
  
  <p>HELP!</p>
  
  <p><strong>ListOnline Class</strong></p>
  
  <pre><code>//firebase
  DatabaseReference onlineRef,currentUserRef,counterRef;
  FirebaseRecyclerAdapter&lt;User,ListOnlineViewHolder&gt; adapter;
  
  //View
  RecyclerView listOnline;
  RecyclerView.LayoutManager layoutManager;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_list_online);
  
      //setting the recyclerview
      listOnline = (RecyclerView)findViewById(R.id.listOnlineRecyclerview);
      listOnline.setHasFixedSize(true);
      layoutManager = new LinearLayoutManager(this);
      listOnline.setLayoutManager(layoutManager);
  
      //set toolbar and menu / join,logout
      Toolbar toolbar = (Toolbar)findViewById(R.id.toolbarID);
      toolbar.setTitle("Presence System");
      setSupportActionBar(toolbar);
  
      //firebase
      onlineRef = FirebaseDatabase.getInstance().getReference().child("info/connected");
      counterRef = FirebaseDatabase.getInstance().getReference("lastOnline"); //create new child name lastOnline
      currentUserRef = FirebaseDatabase.getInstance().getReference().child(FirebaseAuth.getInstance().getCurrentUser().getUid());
  
      setupSystem();
      //after setup we load all users and display in recyclerview
      //this is online list
      updateList();
  }
  
  private void updateList() {
      adapter = new FirebaseRecyclerAdapter&lt;User, ListOnlineViewHolder&gt;(
              User.class,R.layout.user_layout,ListOnlineViewHolder.class,counterRef
      ) {
          @Override
          protected void populateViewHolder(ListOnlineViewHolder viewHolder, User model, int position) {
              viewHolder.emailTextView.setText(model.getEmail());
          }
  
      };
      adapter.notifyDataSetChanged();
      listOnline.setAdapter(adapter);
  }
  
  private void setupSystem() {
      onlineRef.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
                  if(dataSnapshot.getValue(Boolean.class)){
                      currentUserRef.onDisconnect().removeValue();
                      //set online user in list
                      counterRef.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
                              .setValue(FirebaseAuth.getInstance().getCurrentUser().getEmail(),"Online");
                      adapter.notifyDataSetChanged();
                  }
              }
  
  
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
      counterRef.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              for(DataSnapshot postSnapshot:dataSnapshot.getChildren()){
                  User user = postSnapshot.getValue(User.class);
                  Log.d("LOG",""+user.getEmail()+"is "+user.getStatus());
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater menuInflater = getMenuInflater();
      menuInflater.inflate(R.menu.main_menu,menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()){
          case R.id.action_join:
              counterRef.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
                      .setValue(FirebaseAuth.getInstance().getCurrentUser().getEmail(),"Online");
              break;
          case R.id.action_logout:
              currentUserRef.removeValue();
  
      }
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>User Class</strong></p>
  
  <pre><code>public class User {
  private String email,status;
  
  
  public User(String email, String status) {
      this.email = email;
      this.status = status;
  }
  
  public User() {
  
  }
  
  public String getEmail() {
      return email;
  }
  
  public void setEmail(String email) {
      this.email = email;
  }
  
  public String getStatus() {
      return status;
  }
  
  public void setStatus(String status) {
      this.status = status;
  }}
  </code></pre>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  Button signInButton;
  private final static int LOGIN_PERMISSION = 1000;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      signInButton = (Button) findViewById(R.id.signInButton);
      signInButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().setAllowNewEmailAccounts(true).build(),LOGIN_PERMISSION);
  
          }
  
      });
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  
      if(requestCode == LOGIN_PERMISSION){
          startNewActivity(resultCode,data);
      }
  }
  
  private void startNewActivity(int resultcode, Intent data) {
  
      if(resultcode == RESULT_OK){
          Intent intent = new Intent(MainActivity.this,ListOnline.class);
          startActivity(intent);
          finish();
  
      }
      else{
          Toast.makeText(this,"login failed!!",Toast.LENGTH_SHORT).show();
      }
  }}
  </code></pre>