I have some code which should allow a user to delete a folder (which it does) then it should be removed from the ‘recent folders’ list - however it is not. The folder remains on the ‘recent folders’ list even after the user has deleted it - which is undesired.
/**
* Add recent folders to the list in order as acquired by the {@link RecentFolderList}.
*
* @param destination List of drawer items to populate
*/
private void addRecentsToList(List<DrawerItem> destination) {
    // If there are recent folders, add them.
    final List<Folder> recentFolderList = getRecentFolders(mRecentFolders);
    // Remove any excluded folder types
    if (mExcludedFolderTypes != null) {
        final Iterator<Folder> iterator = recentFolderList.iterator();
        while (iterator.hasNext()) {
            if (isFolderTypeExcluded(iterator.next())) {
                iterator.remove();
            }
        }
    }
    if (recentFolderList.size() > 0) {
        destination.add(DrawerItem.ofHeader(mActivity, R.string.recent_folders_heading,
        mBidiFormatter));
        // Recent folders are not queried for position.
        for (Folder f : recentFolderList) {
            destination.add(DrawerItem.ofFolder(mActivity, f, DrawerItem.FOLDER_RECENT,
            mBidiFormatter));
        }
    }
}
The strange part is if I perform an orientation change - the folders are removed from the 'recent folders list' as desired - and I’m unsure as to why this might be happening.
I have a feeling the list may simply need to be refreshed (after the folder has been deleted) however I am unsure.
Any suggestions, clues or pointers are greatly appreciated.
Full Source:
P.S.
Calling notifyDataSetChanged() on the adapter (as suggested by one of the answers below - and whomever flagged this as a duplicate - does not seem to have any effect)
 
     
     
    