Why do i keep throwing a NullPointerException? : <p>I am trying to load the active users information into a new activity and display it. I have done similar things in different activities and they have worked fine, but for some reason this is not and I am not sure. Whenever android studio tries to invoke a method on user, it throws a NullPointerException.</p>

<p>I have tried everything I can think of, reformatting the way its written, nesting in different methods, passing data through to it in different ways. Nothing is working and every article I've found on the subject doesnt help at all</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_edit);
    int userID = getIntent().getIntExtra("sessionUser", 0);
    tuckBoxDao = TuckBoxDB.createTuckBoxDB(this).tbDao();

    Email = findViewById(R.id.email);
    Username = findViewById(R.id.username);
    Password = findViewById(R.id.password);
    Mobile = findViewById(R.id.phoneNumber);
    Notifications = findViewById(R.id.notificationBox);
    Emails = findViewById(R.id.emailBox);
    registerButton = findViewById(R.id.registerButton);
    registerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            registerUser(user);
        }
    });

    backButton = findViewById(R.id.backButton);
    backButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            goBack();
        }
    });

    user = LoginActivity.tuckBoxDB.tbDao().searchById(userID);

    String username = user.getUsername();
    Username.setText(username);
    String email = user.getEmail();
    Email.setHint(email);
    String mobile = user.getMobile();
    Mobile.setHint(mobile);
    Boolean notifications = user.getNotifications();
    Notifications.setChecked(notifications);
    Boolean emails = user.getEmails();
    Emails.setChecked(emails);

}
</code></pre>

<p>I would have expected this to work fine and update and display the right information, as it has done exactly that in a fragment I made earlier, but for some reason it is throwing as soon as it gets to user.getUsername();</p>
