Function to set a Object value to preference
String key for calling it later
model value to store
Class to map into json object