title: How to handle ConcurrentModificationException in Android
body: <p>Im trying to delete item from a <code>ArrayList</code>. <em>Some times</em> it pops an exception, <code>java.util.ConcurrentModificationException</code>.</p>
  <p>First I tried to remove them by <code>array_list_name.remove(i)</code>, but it failed and some people were asked to use Iterator instead. So my current code is as follows:</p>
  <pre><code>for (Iterator&lt;Collectable&gt; iter = array_list_name.iterator(); iter.hasNext();) {
     Collectable s = iter.next();
     if (s.equals(array_list_name.get(id))){
         iter.remove();
         return true;
     }
  }
  </code></pre>
  <p>And I call <code>array_list_name</code> inside <code>onDraw()</code> function in view. My view is a <code>SurfaceView</code>. Can anyone suggest me how to delete items from <code>ArrayList</code> without getting this error?</p>