Android Exception : Concurentmodificationexception
I am getting this exception inconsistently while listview loading on back press from details of the item, which we selected. when I am going on this listview page it never throws e
Solution 1:
synchronized (this) {
for (listModel current_item : items) {
String current_section = current_item.getName().substring(0, 1).toUpperCase(Locale.getDefault());
if (!prev_section.equals(current_section)) {
mListItems.add(current_section);
mListItems.add(current_item.getName());
// array list of section positions
mListSectionPos.add(mListItems.indexOf(current_section));
prev_section = current_section;
} else {
mListItems.add(current_item.getName());
}
}
}
The problem synchronized (this)
. Since you didn't provide stacktrace, I don't know the exception is thrown by which operation.
For example , if your exception is caused by multi-thread access to items , you can just replace this
with items
.
Post a Comment for "Android Exception : Concurentmodificationexception"