java.util.ConcurrentModificationException in EndlessAdapter in Android
<p>I am getting this exception:</p>

<pre><code>06-09 13:14:41.917: E/AndroidRuntime(630): java.util.ConcurrentModificationException
06-09 13:14:41.917: E/AndroidRuntime(630): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)  
</code></pre>

<p>I use the following <a href="https://github.com/commonsguy/cwac-endless" rel="nofollow"><code>EndlessAdapter</code></a>:</p>

<pre><code>  private class DemoAdapter extends EndlessAdapter {

    private RotateAnimation rotate=null;

    DemoAdapter(ArrayList&lt;Outlets&gt; outletList) {
        super(new OutletListAdapter(VerticalsListActivity.this, outletList));

        rotate=new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF,
                                    0.5f, Animation.RELATIVE_TO_SELF,
                                    0.5f);
        rotate.setDuration(600);
        rotate.setRepeatMode(Animation.RESTART);
        rotate.setRepeatCount(Animation.INFINITE);
      }

    @Override
    protected View getPendingView(ViewGroup parent) {
      View row=getLayoutInflater().inflate(R.layout.row, null);

      View child=row.findViewById(android.R.id.text1);

      child.setVisibility(View.GONE);

      child=row.findViewById(R.id.throbber);
      child.setVisibility(View.VISIBLE);
      child.startAnimation(rotate);

      return(row);
    }
    @Override
    protected boolean cacheInBackground() throws Exception {
        // TODO Auto-generated method stub
        if(isMoreLoading){
            try {   
                if(Project.isFilterEnabled){
                    getDownloadedData = (FetchAndParseData) new FetchAndParseData().execute(Project.searchUrl+"/pageno/"+ ++i);
                }else{
                    getDownloadedData = (FetchAndParseData) new FetchAndParseData().execute(UrlConstants.OUTLETS_INFO_URL+Project.currentCityId+"/pageno/"+ ++i+"/verticalid/1");
                }
                inputStream = getDownloadedData.get();
                XmlUtilities.parseAndLoadData(inputStream , mOutletXmlHandler);
                outletList = Project.getOutletList();//Project.getOutletList();




            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }               
        return isMoreLoading;
    }

    @Override
    protected void appendCachedData() {
        // TODO Auto-generated method stub


        adptr = (OutletListAdapter) getWrappedAdapter();
        if(outletList.size()==20){
            isMoreLoading=true;
        }else{
            isMoreLoading=false;
        }           

        if(outletList!=null){
            for (Outlets addThis : outletList) {
                adptr.add(addThis);
            }
        }

    }

  }
</code></pre>

<p>Now, when a list contains less than 20 elements and we scroll that list it throws mentioned exception. Whats am I doing wrong?</p>
