Code example for Gson

Methods: toJson

0
			editor.remove(key);
			editor.commit();
		} else { 
			SharedPreferences prefs = obj.isPersistent() ? persistentSettings : settings;
			Editor editor = prefs.edit();
			editor.putString(key, gson.toJson(obj));
			editor.putString(key + CLASS_SUFFIX, obj != null ? obj.getClass().getName() : null);
			editor.commit();
		} 
		LogIt.d(this, "TIMER " + key + ": " + (System.currentTimeMillis() - start));
	} 
 
	@Override 
	public CoreObject get(String key) {
		SharedPreferences prefs = settings;
		String objString = prefs.getString(key, null);
		if (objString == null) {
			prefs = persistentSettings;
			objString = prefs.getString(key, null);
		} 
Experience pair programming with AI  Get Codota for Java