Code example for Gson

Methods: toJson

0
		return current;
	} 
	 
	public void save(Context context)
	{ 
		Gson gson = new Gson();
		String json = gson.toJson(this);
		 
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		//SharedPreferences prefs = activity.getSharedPreferences("settings", 0); 
	    SharedPreferences.Editor editor = prefs.edit();
	    //editor.putString("json", json); 
	    editor.putString("settings", json);
	    editor.commit();
	} 
	 
	public static void load(Context context)
	{ 
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		String json = prefs.getString("settings","");