I'm going to manage received message from server in my android client. For this goal I'm using ArrayList(HashMap<String, Integer>)
to store arrived messages.
private ArrayList<HashMap<String, Integer>> Notifications = new ArrayList<>();
Each message has a type and I store that in hash map as a key
and put qty of that type of message as integer in HashMAp
too as value
.
Now I got CME
when I'm trying to iterate over ArrayList
to find and update or add new type of arrived messages.
I think, I did it in a right way, where is my fault:
for(HashMap<String, Integer> pack : Notifications) {
// Searching for Notification Type - If exist update the value
for(Entry<String, Integer> item : pack.entrySet()){
String key = item.getKey();
if(key.equals(type)){
Log.e("We find the key here:", key);
item.setValue(item.getValue()+1);
found = true;
break;
}
}
if(!found){
........
}
}