title: How to check if my list already contains a certain string. Java Android SDK
body: <p>I have a list:</p>
  
  <pre><code>List&lt;String&gt; oldfavs = new ArrayList&lt;String&gt;();
  </code></pre>
  
  <p>I have intialized</p>
  
  <pre><code>private TextView insult;
  </code></pre>
  
  <p>where</p>
  
  <pre><code>insult = (TextView) findViewById(R.id.insult);
  </code></pre>
  
  <p>and I want to be able to check if the string I am about to add is already in the list if it is in the List I don't want to add it:</p>
  
  <p>Here's what I currently have:</p>
  
  <pre><code>public void SaveInsult(View view) {
      String saved = insult.getText().toString();
          if (oldfavs.contains(saved)) {
              Toast.makeText(getApplicationContext(), R.string.alreadyinfavs, Toast.LENGTH_SHORT).show();
          }
          else {
              int listSize = oldfavs.size();
              for (int i = 0; i &lt; listSize; ++i)
              oldfavs.add(saved);
              Toast.makeText(getApplicationContext(), R.string.addedfavs, Toast.LENGTH_SHORT).show();
          }
  }
  </code></pre>
  
  <p>However at the moment the string is always added even if the string is already in the list and I can't work out why or where I am going wrong. </p>