title: Stopping an Android Activity, use noHistory="true"
body: <p>I had read about this thread around the Internet but I haven't found the solution. The solutions like :noHistory="true" in the Manifest file. What I wanted is that after the user clicks the save button in AddNewItem class, which will redirect the user into the MainActivity class, when the user clicks the back button, it will go back to the mainMenu, no going back at every step I have made.             </p>
  
  <p>This is my manifest file</p>
  
  <pre><code> &lt;activity
              android:name="com.example.shoppingapp.AddNewItems"
              android:label="" 
               android:noHistory="true"&gt;
  
          &lt;/activity&gt;
  </code></pre>
  
  <p>This is my mai activity></p>
  
  <pre><code>public class MainActivity extends ListActivity {
  
      // The Intent is used to issue that an operation should
      // be performed
  
      Intent intent;
      TextView itemId;
  
      // The object that allows me to manipulate the database
  
      ShoppingDB shopdatabase = new ShoppingDB(this);
  
      // Called when the Activity is first called
  
      protected void onCreate(Bundle savedInstanceState) {
          // Get saved data if there is any
  
          super.onCreate(savedInstanceState);
  
          // Designate that edit_contact.xml is the interface used
          // is activity_main.xml
  
          setContentView(R.layout.activity_main);
  
          // Gets all the data from the database and stores it
          // in an ArrayList
  
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; contactList =  shopdatabase.getAllItems();
  
          // Check to make sure there are contacts to display
  
          if(contactList.size()!=0) {
  
              // Get the ListView and assign an event handler to it
  
              ListView listView = getListView();
              listView.setOnItemClickListener(new OnItemClickListener() {
  
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view,int position, long id) {
  
                      // When an item is clicked get the TextView
                      // with a matching checkId
  
                      itemId = (TextView) view.findViewById(R.id.itemId);
  
                      // Convert that itemId into a String
  
                      String itemIdValue = itemId.getText().toString();   
  
                      // Signals an intention to do something
                      // getApplication() returns the application that owns
                      // this activity
  
                      Intent  theIndent = new Intent(getApplication(),EditItemList.class);
  
                      // Put additional data in for EditContact to use
  
                      theIndent.putExtra("itemId", itemIdValue); 
  
                      // Calls for EditContact
  
                      startActivity(theIndent); 
  
                                      }
              }); 
  
              // A list adapter is used bridge between a ListView and
              // the ListViews data
  
              // The SimpleAdapter connects the data in an ArrayList
              // to the XML file
  
              // First we pass in a Context to provide information needed
              // about the application
              // The ArrayList of data is next followed by the xml resource
              // Then we have the names of the data in String format and
              // their specific resource ids
  
              ListAdapter adapter = new SimpleAdapter( MainActivity.this,contactList, R.layout.item_list_entry, new String[] { "itemId","textAmount", "textItem"}, new int[] {R.id.itemId, R.id.textAmount, R.id.textItem});
  
              // setListAdapter provides the Cursor for the ListView
              // The Cursor provides access to the database data
  
              setListAdapter(adapter);
  
  
          }
  
      }
  
  
      public void callStartApp(View view){
  
          Intent startIntent = new Intent(getApplication(), StartingApp.class);
  
          startActivity(startIntent);
  
      }
  
      // When showAddContact is called with a click the Activity 
      // NewContact is called
  
      public void showAddItem(View view) {
          Intent theIntent = new Intent(getApplicationContext(), AddNewItems.class);
          startActivity(theIntent);
      }
  
  
  }
  </code></pre>
  
  <p>and this is my AddNewItem class</p>
  
  <pre><code>public class AddNewItems extends Activity {
  
      // The EditText objects
  
          EditText textItem;
          EditText textAmount;
          EditText textPrice;
          EditText textPlace;
  
          ShoppingDB shopdatabase = new ShoppingDB(this);
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
  
      // Get saved data if there is any
  
      super.onCreate(savedInstanceState);
  
      // Designate that add_new_item.xml is the interface used
  
      setContentView(R.layout.add_item);
  
      // Initialize the EditText objects
  
      textItem = (EditText) findViewById(R.id.textItem);
      textAmount = (EditText) findViewById(R.id.textAmount);
      textPrice = (EditText) findViewById(R.id.textPrice);
      textPlace = (EditText) findViewById(R.id.textPlace);
  
  
  }
  public void addNewItems(View view) {
  
      // Will hold the HashMap of values 
  
      HashMap&lt;String, String&gt; queryValuesMap =  new  HashMap&lt;String, String&gt;();
  
      // Get the values from the EditText boxes
  
      queryValuesMap.put("textItem", textItem.getText().toString());
      queryValuesMap.put("textAmount", textAmount.getText().toString());
      queryValuesMap.put("textPrice", textPrice.getText().toString());
      queryValuesMap.put("textPlace", textPlace.getText().toString());
  
  
      // Call for the HashMap to be added to the database
  
      shopdatabase.insertItem(queryValuesMap);
  
      // Call for MainActivity to execute
  
      this.callMainActivity(view);
  }
  public void callMainActivity(View view) {
      Intent theIntent = new Intent(getApplicationContext(), MainActivity.class);
      startActivity(theIntent);
  }   
  }
  </code></pre>