public static void checkForDuplicateNames ( Map < String , Boolean > isDuplicateName , Cursor cursor , int nameIndex ) { isDuplicateName . clear ( ) ; cursor . moveToPosition ( - 1 ) ; while ( cursor . moveToNext ( ) ) { String displayName = cursor . getString ( nameIndex ) ; // Set it to true if we've seen this name before, false otherwise if ( displayName != null ) { isDuplicateName . put ( displayName , isDuplicateName . containsKey ( displayName ) ) ; } } }
Scan through a cursor of calendars and check if names are duplicated . This travels a cursor containing calendar display names and fills in the provided map with whether or not each name is repeated .