-2

I've been searching for a method that passes the data from one activity to another. I found several ways to do so. Even here i found many people asking this question! I tried to solve this problem as I found here and in many other websites (using the intent). But it is no use! this is really weird because the intent method works with everyone else but when I try, it doesn't work at all really I don't know what is wrong with my code!!! I just want to pass the username and the birthday from Register activity to Profiles activity, here is what I've tried so far:

private TextInputLayout textInputLayoutName;
private TextInputLayout textInputLayoutEmail;
private TextInputLayout textInputLayoutBirthday;

private TextInputEditText textInputEditTextName;
private TextInputEditText textInputEditTextEmail;
private TextInputEditText textInputEditTextBirthday;

if (!databaseHelper.checkUser(textInputEditTextEmail.getText().toString().trim())) {

        user.setName(textInputEditTextName.getText().toString().trim());
        user.setEmail(textInputEditTextEmail.getText().toString().trim());
        user.setPassword(textInputEditTextPassword.getText().toString().trim());

        databaseHelper.addUser(user);

        Snackbar.make(nestedScrollView, getString(R.string.success_message), Snackbar.LENGTH_LONG).show();
        emptyInputEditText();

        Intent intent = new Intent(RegisterActivity.this, ProfilesActivity.class);
        intent.putExtra("username", textInputEditTextName.getText().toString());
        intent.putExtra("birthday", textInputEditTextBirthday.getText().toString());
        startActivity(intent);

and here is how I get them from the Profiles activities in the OnCreate method:

        private TextView theName;
 private TextView theBirthday;
    theName= (TextView) findViewById(R.id.theName);
            theBirthday=(TextView) findViewById(R.id.theBirthday);
            Intent intent = getIntent();
            String username = intent.getStringExtra("username");
            String birthday = intent.getStringExtra("birthday");
            theName.setText(username);
            theBirthday.setText(birthday);

It shows me nothing in the Profiles activity! I don't now what is the wrong here! please help if you know where my issue is !

for editor: I found so many similar questions but my problem is different

ASKWWW
  • 11
  • 2
  • Please check this answer : https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application/7325248#7325248 – Itzik Samara Sep 18 '17 at 16:30
  • 3
    Possible duplicate of [How do I pass data between Activities in Android application?](https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application) – Jason Sep 18 '17 at 16:59

1 Answers1

0

If this method

emptyInputEditText()

does what it says, that's why you're not getting (in fact sending) any data to your ProfilesActivity.

Crispert
  • 1,102
  • 7
  • 13
  • OMG, I just can't believe that I didn't pay attention for this, now it is finally working thank you so much and sorry for being so stupid! – ASKWWW Sep 18 '17 at 19:31
  • If I had a nickel for all the times I did similar stuff I wouldn't need a job :) – Crispert Sep 18 '17 at 19:33