title: Remove items from Array List stored in shared preferences
body: <p>I have a shopping cart where I want to delete a product but I'm facing an issue.
  I can add the product and store it in shared preferences, but when it comes to delete nothing happens. Here is my code in adapter:</p>
  
  <pre><code>holder.removeProduct.setOnClickListener(v -&gt; {
              SharedPreferences preferences = mContext.getSharedPreferences(ITEMS_PREF, Context.MODE_PRIVATE);
              SharedPreferences.Editor mEditor = preferences.edit();
              Gson gson = new Gson();
              String json = preferences.getString("artikujtShporta", "");
              ArrayList&lt;Artikujt&gt; artikullObject = gson
                      .fromJson(json, new TypeToken&lt;ArrayList&lt;Artikujt&gt;&gt;(){}.getType());
  
              if (artikullObject != null) {
                  artikullObject.remove(artikulli);
                  String jsonString = gson.toJson(artikullObject);
                  mEditor.putString("artikujtShporta", jsonString);
                  mEditor.apply();
              }
          });
  </code></pre>
  
  <p>The same code I used to add product, with arraylist.add(). What I'm doing wrong here, can someone help.</p>
  
  <p>edit:</p>
  
  <pre><code>holder.addItems.setOnClickListener(v -&gt; {
              //listener.setCounter(0);
              SharedPreferences preferences = mContext.getSharedPreferences(ITEMS_PREF, Context.MODE_PRIVATE);
              SharedPreferences.Editor mEditor = preferences.edit();
              Gson gson = new Gson();
              String json = preferences.getString("artikujtShporta", "");
              ArrayList&lt;Artikujt&gt; artikullObject = gson
                      .fromJson(json, new TypeToken&lt;ArrayList&lt;Artikujt&gt;&gt;(){}.getType());
  
              if (artikullObject != null) {
                  artikullObject.add(mArtikull);
                  String jsonString = gson.toJson(artikullObject);
                  mEditor.putString("artikujtShporta", jsonString);
                  mEditor.apply();
              } else {
                  ArrayList&lt;Artikujt&gt; arrayArtikuj = new ArrayList&lt;&gt;();
                  arrayArtikuj.add(mArtikull);
                  Type listOfTestObject = new TypeToken&lt;ArrayList&lt;Artikujt&gt;&gt;(){}.getType();
                  String s = gson.toJson(arrayArtikuj, listOfTestObject);
                  mEditor.putString("artikujtShporta", s);
                  mEditor.apply();
              }
  
          });
  </code></pre>