I'm trying to show an extra menu item (contextual action bar) when the user selects one/multiple items in a ListView. Basically I'm checking if the selected item has a field in the DB set to true. If so, I add the extra menu item.
I tried to query the DB for the selected item in onItemCheckedStateChanged() and invalidate the menu. This will call onPrepareActionMode() where I could show the extra option if needed.
This does not work because the options that are already selected with the DB column set to true, are not remembered when an item with the special DB column set to false gets selected in onItemCheckedStateChanged() and when onPrepareActionMode() gets called the extra menu item is removed.
How can I approach this better? Essentially I need a way to remember all the selected ListView items that have the extra field in the DB set to true so I can show the extra menu item - and vice-versa remove the item when none of the selected ListView items has that DB field.