Code example for SparseBooleanArray

Methods: put

0
         * We use the previous bookmarked shortcuts array to filter out those 
         * shortcuts that had bookmarks before this method call, and don't after 
         * (so we can set the preferences to be without bookmarks). 
         */ 
        SparseBooleanArray noLongerBookmarkedShortcuts = mBookmarkedShortcuts;
        SparseBooleanArray newBookmarkedShortcuts = new SparseBooleanArray(); 
        while (c.moveToNext()) {
            char shortcut = Character.toLowerCase((char) c.getInt(COLUMN_SHORTCUT));
            if (shortcut == 0) continue;
             
            ShortcutPreference pref = getOrCreatePreference(shortcut);
            pref.setTitle(Bookmarks.getTitle(this, c));
            pref.setSummary(getString(R.string.quick_launch_shortcut,
                    String.valueOf(shortcut)));
            pref.setHasBookmark(true);
             
            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);
            }