} else if (value instanceof Double || value instanceof Float) {
prefs.putDouble(keyStr, ((Number) value).doubleValue());
} else if (value instanceof Number) {
prefs.putLong(keyStr, ((Number) value).longValue());
} else if (value instanceof Scriptable) {
ScriptEngine engine = ScriptEngine.getEngineByName("JavaScript");
Context cx = Context.getCurrentContext();
Object json = NativeJSON.stringify(cx,
((RhinoScope) engine.getGlobalScope()).getScope(), value,
null, null);
prefs.put(keyStr, json != null ? json.toString() : "null");
} else if (value instanceof String) {
prefs.put(keyStr, value.toString());
}