title: Increment an integer variable?
body: <p>I am having a problem incrementing my integer variable after a certain condition is met in Android Programming. Why is it not incrementing?</p>
  
  <p>The code below are implemented on an ImageButton which lies a class (Activity) called Product.</p>
  
  <pre><code>int count = 1;
  
  List&lt;Item&gt; prod = ShoppingCart.getInstance().getProducts();
  
  // if arraylist is null --&gt; add a product
  if(prod != null &amp;&amp; prod.isEmpty()){
      ShoppingCart.getInstance().addItem(new Item(
              namePureString,
              manufacturePureString,
              pricePureString,
              "",
              count
      ));
      Toast.makeText(getApplicationContext(), namePureString + " Added To Cart", Toast.LENGTH_SHORT).show();
  
  }else {
  
      for (Item products : ShoppingCart.getInstance().myProducts) {
  
          // here i am checking if the product exists, if it does --&gt; count has to increment
          if (products.getManufacture().equals(manufacturePureString)) {
  
              count += count;
              Toast.makeText(getApplicationContext(), "You Added This Product\nQuantity Will Increase",
                      Toast.LENGTH_SHORT).show();
  
              ShoppingCart.getInstance().setItemExists(new Item(
                      namePureString,
                      manufacturePureString,
                      pricePureString,
                      "",
                      count
              ));
  
              } else {
              ShoppingCart.getInstance().addItem(new Item(
                      namePureString,
                      manufacturePureString,
                      pricePureString,
                      "",
                      count
              ));
          }
  }
  </code></pre>
  
  <p>This is my Singleton class, in which I call its methods:</p>
  
  <pre><code>public class ShoppingCart {
  
      private static final String TAG = "Products: ";
      private static ShoppingCart ourInstance = null;
  
      public ArrayList&lt;Item&gt; myProducts = new ArrayList&lt;&gt;();
  
      private ShoppingCart() {
      }
  
      public static ShoppingCart getInstance() {
          // if object instance does not exist create a new one and use that one only
          if ( ourInstance == null){
              ourInstance = new ShoppingCart();
          }
          return ourInstance;
      }
  
      public void addItem(Item item){
              ourInstance.myProducts.add(item);
      }
  
      public void setItemExists(Item item) {
          int itemIndex = ourInstance.myProducts.indexOf(item);
          if (itemIndex != -1) {
              ourInstance.myProducts.set(itemIndex, item);
          }
      }
  
      public List&lt;Item&gt; getProducts(){
          return this.myProducts;
      }
  }
  </code></pre>