Code example for Map

Methods: containsKeyputremove

        SharedPreferences prefs = getSharedPreferences(branch);
        boolean enable = message.getBoolean("enable");
        // mListeners is only modified in this one observer, which is called 
        // from Gecko serially. 
        if (enable && !this.mListeners.containsKey(branch)) {
            SharedPreferences.OnSharedPreferenceChangeListener listener = new ChangeListener(branch);
            this.mListeners.put(branch, listener);
        if (!enable && this.mListeners.containsKey(branch)) {
            SharedPreferences.OnSharedPreferenceChangeListener listener = this.mListeners.remove(branch);
    public void handleMessage(String event, JSONObject message) {
        // Everything here is synchronous and serial, so we need not worry about 
        // overwriting an in-progress response. 
Stop searching for code, let great code find you!  Add Codota to your java IDE