Code example for SparseBooleanArray

Methods: keyAtputsizevalueAt

0
             
            newBookmarkedShortcuts.put(shortcut, true);
            if (noLongerBookmarkedShortcuts != null) {
                // After this loop, the shortcuts with value true in this array 
                // will no longer have bookmarks 
                noLongerBookmarkedShortcuts.put(shortcut, false);
            } 
        } 
         
        if (noLongerBookmarkedShortcuts != null) {
            for (int i = noLongerBookmarkedShortcuts.size() - 1; i >= 0; i--) {
                if (noLongerBookmarkedShortcuts.valueAt(i)) {
                    // True, so there is no longer a bookmark for this shortcut 
                    char shortcut = (char) noLongerBookmarkedShortcuts.keyAt(i);
                    ShortcutPreference pref = mShortcutToPreference.get(shortcut);
                    if (pref != null) {
                        pref.setHasBookmark(false);
                    } 
                } 
            }