Search code examples
javaandroidarraylisthashmap

How to remove an item from ArrayList<HashMap<String, Object>>


I'm using an ArrayList<HashMap<String, Object>> to store items in. I know how to add an item to this list, but I don't know how to remove one. I've tried many things, such as list.remove(position); but nothing was working. I've searched on Google and read tons of similar questions which didn't help me at all. My question is: How to remove an item from the list?

My list:

[
    { title=MyFirstElement, comments=First element of my list },
    { title=ASecondOne, comments=Two elements },
    { title=Third, comments=Never two without three }
]

Solution

  • Could you please post the complete stacktrace. The eror you have mentioned is not relate to what you think. Its something relates to Json.

    In general,

    list.remove(index)

    should work in your case.