title: When im pressing back button my list items are getting deleted
body: <p>In this activity i was trying to store data dynamically but when im pressing back button in my emulator my list items are getting deleted.....</p>
  
  <p>This is my main activity...</p>
  
  <pre><code>      public class Dynamic extends Activity {
  
      Button bt,bt2;
      EditText et,et2;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          bt = (Button) findViewById(R.id.nameok);
          et = (EditText) findViewById(R.id.name);
  
          final String input = et.getText().toString();
  
          bt.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View v) {
  
                  if (et.getText().length() == 0) {
                      Context context = getApplicationContext();
                      CharSequence text = "Enter Your Name";
                      int duration = Toast.LENGTH_SHORT;
  
                      Toast toast = Toast.makeText(context, text, duration);
                      toast.show();
                  } else {
                      if (et.getText().length() == 0) {
                          Context context = getApplicationContext();
                          CharSequence text = "Enter Your Number";
                          int duration = Toast.LENGTH_SHORT;
  
                          Toast toast = Toast.makeText(context, text, duration);
                          toast.show();
                      } else {
                      et2.setVisibility(View.VISIBLE);
                      bt2.setVisibility(View.VISIBLE);
                        bt2.setOnClickListener(new View.OnClickListener() {
  
                          @Override
                          public void onClick(View v) {
                              // TODO Auto-generated method stub
                              String input = et.getText().toString();
                              String input1 = et2.getText().toString();
                              Intent in = new Intent(Dynamic.this, GetList.class);
                              in.putExtra("input", input);
                              in.putExtra("input1", input1);
                              startActivity(in);
  
  
                          }
                      });
  
                  }
                  }
              }
          });
      }
      protected void onStart() {
          // TODO Auto-generated method stub
          super.onStart();
  
          et2 = (EditText) findViewById(R.id.number);
          bt2 = (Button) findViewById(R.id.numberok);
  
      }
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p>this is my list where im giving
  List:</p>
  
  <pre><code>  public class GetList extends Activity {
  public void onCreate(Bundle savedInstanceState) {
      ListView lv;
      Button bt3;
  
      ArrayAdapter&lt;String&gt; a_adapter;
      ArrayList&lt;String&gt; x_listItems;
      ArrayList&lt;String&gt; y_listItems;
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.list);
  
      lv = (ListView) findViewById(R.id.listView1);
      bt3 = (Button) findViewById(R.id.nameok1);
      bt3.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Intent in3=new Intent(GetList.this,Dynamic.class);
              startActivity(in3);
          }
      });
  
      x_listItems = new ArrayList&lt;String&gt;();
      y_listItems = new ArrayList&lt;String&gt;();
  
      a_adapter = new ArrayAdapter&lt;String&gt;(this,
              android.R.layout.simple_list_item_1, x_listItems);
  
      lv.setAdapter(a_adapter);
  
      Intent in = getIntent();
  
      String inp = in.getStringExtra("input");
      String inp1 = in.getStringExtra("input1");
  
      if (null != inp &amp;&amp; inp.length() &gt; 0) {
          x_listItems.add(inp);
  
          a_adapter.notifyDataSetChanged();
      }
      if (null != inp1 &amp;&amp; inp1.length() &gt; 0) {
          y_listItems.add(inp1);
          Log.v("num", ""+y_listItems);
  
  
      }
  }
  
       }
  </code></pre>