title: Passing data from one activity to another not working
body: <p>settings.java</p>
  
  <pre><code>public class settingsActivity extends MainActivity  {
  
  
      private TextView mTextMessage;
      Intent i=new Intent();
  
  
      Button saveButton;
  
      private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
              = new BottomNavigationView.OnNavigationItemSelectedListener() {
  
          @Override
          public boolean onNavigationItemSelected(@NonNull MenuItem item) {
              goalDate = findViewById(R.id.goaldinput);
              goalWeight = findViewById(R.id.goalwinput);
              nameIn = findViewById(R.id.nameinput);
              fT=findViewById(R.id.feet);
              iNches=findViewById(R.id.inches);
              mAle=findViewById(R.id.maleButton);
              feMale=findViewById(R.id.othersButton);
              oThers=findViewById(R.id.femaleButton);
              switch (item.getItemId()) {
                  case R.id.navigation_home:
                      mTextMessage.setText(R.string.title_home);
                      Intent intent1 = new Intent(settingsActivity.this, MainActivity.class);
                      startActivity(intent1);
                      break;
                  case R.id.navigation_history:
                      mTextMessage.setText(R.string.title_history);
                      Intent intent2 = new Intent(settingsActivity.this, historyActivity.class);
                      startActivity(intent2);
  
                      break;
                  case R.id.navigation_progress:
                      mTextMessage.setText(R.string.title_progress);
                      Intent intent3 = new Intent(settingsActivity.this, progressActivity.class);
                      startActivity(intent3);
                      break;
                  case R.id.navigation_settings:
                      mTextMessage.setText(R.string.title_settings);
                      Intent intent4 = new Intent(settingsActivity.this, settingsActivity.class);
                      startActivity(intent4);
                      break;
              }
              return false;
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_settings);
  
          mTextMessage = (TextView) findViewById(R.id.message);
          BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
          navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
  
  
          saveButton=findViewById(R.id.saveButton);
  
          saveButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  EditText goalD = ((EditText)findViewById(R.id.goaldinput));
                  EditText goalW = ((EditText)findViewById(R.id.goalwinput));
                  EditText currentW = ((EditText)findViewById(R.id.currentWinput));
                  i = new Intent(settingsActivity.this,historyActivity.class);
                  gD=goalD.getText().toString();
                  gW=goalW.getText().toString();
                  cW=currentW.getText().toString();
                  i.putExtra("goalDate",gD);
                  i.putExtra("goalWeight",gW);
                  i.putExtra("currentWeight",cW);
                  startActivity(i);
  
  /*
                  arrayList1.add(goalD.toString());
                  arrayList2.add(goalW.toString());
                  arrayList3.add(currentW.toString());
  */
  
  
  //                adapter1.notifyDataSetChanged();
                //  adapter2.notifyDataSetChanged();
                 // adapter3.notifyDataSetChanged();
  
              }
          });
  
  
      }
  
  
  </code></pre>
  
  <p>history.java</p>
  
  <pre><code>   public class historyActivity extends MainActivity {
      private TextView mTextMessage;
  
      private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
              = new BottomNavigationView.OnNavigationItemSelectedListener() {
  
          @Override
          public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  
  
  
              switch (item.getItemId()) {
                  case R.id.navigation_home:
                      mTextMessage.setText(R.string.title_home);
                      Intent intent1 = new Intent(historyActivity.this, MainActivity.class);
                      startActivity(intent1);
                      break;
                  case R.id.navigation_history:
                      mTextMessage.setText(R.string.title_history);
                      Intent intent2 = new Intent(historyActivity.this, historyActivity.class);
                      startActivity(intent2);
                      break;
                  case R.id.navigation_progress:
                      mTextMessage.setText(R.string.title_progress);
                      Intent intent3 = new Intent(historyActivity.this, progressActivity.class);
                      startActivity(intent3);
                      break;
                  case R.id.navigation_settings:
                      mTextMessage.setText(R.string.title_settings);
                      Intent intent4 = new Intent(historyActivity.this, settingsActivity.class);
                      startActivity(intent4);
                      break;
              }
              return false;
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_history);
          mTextMessage = (TextView) findViewById(R.id.message);
          BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
          navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
          listView1= findViewById(R.id.goaldlistView);
          listView2= findViewById(R.id.goalwlistView);
          listView3= findViewById(R.id.currentwlistView);
  
          EditText goalD = ((EditText)findViewById(R.id.goaldinput));
          EditText goalW = ((EditText)findViewById(R.id.goalwinput));
          EditText currentW = ((EditText)findViewById(R.id.currentWinput));
  
         gDate = getIntent().getExtras().getString("goalDate");
          gWeight = getIntent().getExtras().getString("goalWeight");
          cWeight = getIntent().getExtras().getString("currentWeight");
  
          String addArray1[] = {"3/14/1992"};
          String addArray2[] = {"152"};
          String addArray3[] = {"160"};
  
          arrayList1=new ArrayList&lt;String&gt;(Arrays.asList(addArray1));
          arrayList2=new ArrayList&lt;String&gt;(Arrays.asList(addArray2));
          arrayList3=new ArrayList&lt;String&gt;(Arrays.asList(addArray3));
          arrayList1.add(gDate);
          arrayList2.add(gWeight);
          arrayList3.add(cWeight);
          adapter1 = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,arrayList1);
          adapter2 = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,arrayList2);
          adapter3 = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,arrayList3);
  
          listView1.setAdapter(adapter1);
          listView2.setAdapter(adapter2);
          listView3.setAdapter(adapter3);
  
  
  
      }
  }
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private TextView mTextMessage;
  
      EditText goalDate ;
      EditText goalWeight ;
      EditText nameIn ;
      EditText fT;
      EditText iNches;
      EditText currentWeight;
      RadioButton mAle;
      RadioButton feMale;
      RadioButton oThers;
  
      public ArrayList&lt;String&gt;arrayList1=new ArrayList&lt;String&gt;();
      public ArrayList&lt;String&gt;arrayList2=new ArrayList&lt;String&gt;();
      public ArrayList&lt;String&gt;arrayList3=new ArrayList&lt;String&gt;();
  
      public ArrayAdapter&lt;String&gt; adapter1;
      public ArrayAdapter&lt;String&gt; adapter2;
      public ArrayAdapter&lt;String&gt; adapter3;
  
      Intent intent =new Intent();
  
      public ListView listView1;
      public ListView listView2;
      public ListView listView3;
  
  
      String gD=" ";
      String gW=" ";
      String cW=" ";
      String gDate=" ";
      String gWeight=" ";
      String cWeight=" ";
  
      ;
      private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
              = new BottomNavigationView.OnNavigationItemSelectedListener() {
  
          @Override
          public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  
              switch (item.getItemId()) {
                  case R.id.navigation_home:
                      mTextMessage.setText(R.string.title_home);
                      Intent intent1 = new Intent(MainActivity.this, MainActivity.class);
                      startActivity(intent1);
                      break;
                  case R.id.navigation_history:
                      mTextMessage.setText(R.string.title_history);
                      Intent intent2 = new Intent(MainActivity.this, historyActivity.class);
                      startActivity(intent2);
  
  
                      break;
                  case R.id.navigation_progress:
                      mTextMessage.setText(R.string.title_progress);
                      Intent intent3 = new Intent(MainActivity.this, progressActivity.class);
                      startActivity(intent3);
                      break;
                  case R.id.navigation_settings:
                      mTextMessage.setText(R.string.title_settings);
                      Intent intent4 = new Intent(MainActivity.this, settingsActivity.class);
                      startActivity(intent4);
                      break;
              }
              return false;
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mTextMessage = (TextView) findViewById(R.id.message);
          BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
          navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
  
      }
  
  </code></pre>
  
  <p>I'm getting the following error when passing data from settings to history:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
  </code></pre>
  
  <p>gDate is where it is erroring out for nullException error for bundle and I think it might go for gWeight and cWeight</p>
  
  <p>I have tried initializing the intent in MainActivity, Setting and History files. Still it is not passing data.</p>
  
  <p>Need to pass the inputs from Settings and display in listView in History</p>