Code example for JSONObject

Methods: puttoString

        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            if (Log.isLoggable(LOGTAG, Log.VERBOSE)) {
                Log.v(LOGTAG, "Got onSharedPreferenceChanged");
            try { 
                final JSONObject msg = new JSONObject();
                msg.put("branch", this.branch);
                msg.put("key", key);
                // Truly, this is awful, but the API impedence is strong: there 
                // is no way to get a single untyped value from a 
                // SharedPreferences instance. 
                msg.put("value", sharedPreferences.getAll().get(key));
                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SharedPreferences:Changed", msg.toString()));
            } catch (JSONException e) {
                Log.e(LOGTAG, "Got exception creating JSON object", e);