title: Remove item from SharedPreference list [android]
body: <p>I want remove checked elements from my list, but not only from main app but from SharedPreferences also. Now, in my app i can remove chcecked elements but not from SharedPreferences, so if i come back to my activity all of removed elements are still visible. Please, help me.</p>
  
  <p>This is my activity:</p>
  
  <pre><code>    SharedPreferences preferences;
      ArrayList&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
      ArrayAdapter&lt;Object&gt; adapter;
      List&lt;String&gt; localization;
      Button btnDelete;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_moje_miejsca);
  
          btnDelete = (Button) findViewById(R.id.btnDelete);
          adapter = new ArrayAdapter&lt;&gt;(this,  android.R.layout.simple_list_item_multiple_choice, list);
          preferences = getSharedPreferences("coordinates", Activity.MODE_PRIVATE);
  
          Set&lt;String&gt; localizationSet = preferences.getStringSet("localization_set", new HashSet&lt;String&gt;());
          localization = new ArrayList&lt;&gt;(localizationSet);
  
          for (String listPosition : localizationSet) {
              list.add(listPosition);
              adapter.notifyDataSetChanged();
          }
  
          setListAdapter(adapter);
  
  
  public void onClickBtnDelete(View view){
  
      SharedPreferences.Editor editor = preferences.edit();
      SparseBooleanArray checkedItemPositions = getListView().getCheckedItemPositions();
      int itemCount = getListView().getCount();
  
      for(int i = itemCount-1; i &gt;= 0; i--){
  
          if(checkedItemPositions.get(i)){
              int position = i + 1;
              adapter.remove(list.get(i));    
  
          }
      }
  
      editor.remove("localization_set").commit();
      itemCount = getListView().getCount();
  
      checkedItemPositions.clear();
      adapter.notifyDataSetChanged();
  
      for (int i = itemCount-1; i &gt;= 0; i--){
  
          localization.add((String) list.get(i));
          setLocalization = new HashSet&lt;String&gt;(localization);
          editor.putStringSet("localization_set", setLocalization).commit();
  
      }
  
  }
  
  }
  </code></pre>