title: How to restore the ListView and get Contents of List when back button in pressed?
body: <p>ActivityB --> Service class --> Populate ListView in ActivityC (as shown below and there is no fragment for it) ---> ActivityD</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 0);
      setLocale(pref.getString("myLocale", null));
  
      setTitle(R.string.title_activity_choose_number);
      setContentView(R.layout.activity_choose_number1);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
      if(savedInstanceState != null ) {
          mobileNumbersList = savedInstanceState.getStringArrayList("mobileNumbers");
      }
      mobileNumbersList = getIntent().getStringArrayListExtra("mobileNumbers");
  
      mobileNumberAdapter = new ArrayAdapter&lt;String&gt;(this,
              R.layout.secnumsinglechoice,
              mobileNumbersList);
  
      numberListView = (ListView) findViewById(R.id.listViewNumberList);
      numberListView.setAdapter(numberAdapter);
      numberListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              String numberChosen = numberAdapter.getItem(position);
              Intent passNumberIntent = new Intent(getBaseContext(), US.class).
                      putExtra(Intent.EXTRA_TEXT, numberChosen);
              startActivity(passNumberIntent);
          }
      });
  }
  </code></pre>
  
  <p>Now when back button is pressed in ActivityD to ActivityC, I am getting null pointer error. I know the reason because this time, I am not passing the intent from ActivityD and ListView, adapter, data is all null.</p>
  
  <p>So when I searched for how to save the state, I came across saveInstanceState, onRestoreInstance and onSaveInstance. But I am still not able to fix the issue. ActivityC doesn't have a fragment.</p>