I have a ArrayList of Metricas. Each Metrica has some properties and another ArrayList lForms. What I want to to is check in the db to see if the form has been filled, and update the lForms. When I do so, I get a ConcurrentModificationException, I don't know how to get rid of it...
public ArrayList<Metrica> addAllForms(ArrayList<Metrica> lMetricas) {
ArrayList<Metrica> newlMet = lMetricas;
ArrayList<Formulario> lForms = null;
ArrayList<Formulario> newlForms;
Metrica newMetrica;
Formulario f;
for (Iterator<Metrica> it = lMetricas.iterator(); it.hasNext();) {
Metrica metrica = it.next();
newlForms = new ArrayList<Formulario>();
lForms = metrica.getlForms();
for (Iterator<Formulario> it2 = lForms.iterator(); it2.hasNext();) {
Formulario form = it2.next();
f = getForm(form);
if (f == null) {
addForm(form, metrica.getId());
Log.e("log", "adding form");
} else
form = f;
Log.e("log", "Getting adding form");
newlForms.add(form);
}
newMetrica = new Metrica();
newMetrica.setlForms(newlForms);
newMetrica.setClienteId(metrica.getClienteId());
newMetrica.setDatoValido(metrica.getDatoValido());
newMetrica.setDescription(metrica.getDescription());
newMetrica.setId(metrica.getId());
newMetrica.setProyectoProductoId(metrica.getProyectoProductoId());
newMetrica.setTipo(metrica.getTipo());
newlMet.add(newMetrica);
}
return lMetricas;
}