Inan Mahmud
Inan Mahmud

Reputation: 244

How can I remove file from downloading list and send it into the downloaded file list?

I'm building a download manager app which can download multiples in parallel. I'm showing the downloading files in a listview where each item has a progressbar showing the download progress.

When a file is dowloaded I want to remove that item from the list. I'm sending progress from service class using localbroadcast manager and updating the list using broadcast receiver.

When a item is removed the app crushes showing IndexOutOfBounds Exception saying index is 1 size is 1.

How can I solve it ?

Upvotes: 0

Views: 64

Answers (1)

Rainmaker
Rainmaker

Reputation: 11100

Your list indexing starts with 0. If you have one element in a list you should access it at index 0 like this

list.get(0); //the first element is received

Upvotes: 0

Related Questions