I'm trying to get all checked items from a list view in a Sparse boolean array and passing that array to a function which shows the user a dialog and on clicking yes does some stuff in the db for the selected items in the Sparse array.
The problem I'm facing is before calling the function I check the size of Sparse array and it shows the correct size but the function I pass it to, as soon as it gets called it shows a size of 0. I have no clue as to why that is happening.
Here is what I'm doing --->
SparseBooleanArray checkedPositions;
switch (item.getId()) {
case delete :
checkedPositions = listView.getCheckedItemPositions();
Log.d(TAG, checkedPositions.size());
confirmDeletion(checkedPositions);
break;
}
And this is the method I'm passing it to --->
confirmDeletion(final SparseBooleanArray checkedPositions) {
Log.d(TAG, checkedPositions.size());
}
For the first log I get correct size but 0 in the second log. I can't figure out what's going wrong. Any help would be much appreciated.