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. 
Connect your IDE to all the code out there  Get Codota for Java