title: NullPointerException with SharedPreferences
body: <p><a href="https://i.stack.imgur.com/OVJoc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OVJoc.png" alt="my logical "></a>I am trying to get a textView from my Main.java file, and when the notification is clicked, it should print it. I know I am to use sharedPreferences for that. I did that. However, it keeps throwing a NullPointerException, but I have called everything i need to call in my NotificationPage.java class so I am not sure what exactly is wrong. Please any help is appreciated.</p>
  
  <p>This is my NotificationPage.java class</p>
  
  <pre><code>import android.app.Activity;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.widget.TextView;
  
  
  public class NotificationPage extends Activity {
  SharedPreferences sp;
  SharedPreferences.Editor edit;
  TextView arrival;
  TextView notifdate;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.notification);
      notifdate=(TextView)findViewById(R.id.textView5);
      arrival=(TextView)findViewById(R.id.textView4);
      sp=getSharedPreferences(arr, MODE_PRIVATE);
      edit=sp.edit();
      sp.getString(arr, null);
      edit=sp.edit();
      edit.putString(arr,sp.getString(arr,null));
      notifdate.setText("Hey!" + sp.getString(arr,null));
      edit.apply();
  }
  </code></pre>
  
  <p>this is the line of code that gets my shared preferences from my other java file</p>
  
  <pre><code>arr=arrival.getText().toString();
  sp=getSharedPreferences(arr,MODE_PRIVATE);
  </code></pre>