I am testing to save current QBUser object into shared preferences through Gson, meaning I would like to save all QBUser fields locally for later use.
I noticed that some fields are defined as serializable and some not. Is there a reason for this? For background information, I am using exclusion pattern that only takes fields with SerializedName annotation defined and using it with my other fields in the class.
See print out:
// Compiled from QBUser.java (version 1.6 : 50.0, super bit)
public class com.quickblox.module.users.model.QBUser extends com.quickblox.core.model.QBEntity {
// Field descriptor #63 Ljava/lang/String;
@com.google.gson.annotations.SerializedName(value="full_name")
protected java.lang.String fullName;
// Field descriptor #63 Ljava/lang/String;
protected java.lang.String email;
// Field descriptor #63 Ljava/lang/String;
protected java.lang.String login;
// Field descriptor #63 Ljava/lang/String;
protected java.lang.String phone;
// Field descriptor #63 Ljava/lang/String;
protected java.lang.String website;
// Field descriptor #73 Ljava/util/Date;
@com.google.gson.annotations.SerializedName(value="last_request_at")
protected java.util.Date lastRequestAt;
// Field descriptor #63 Ljava/lang/String;
@com.google.gson.annotations.SerializedName(value="external_user_id")
protected java.lang.String externalId;
// Field descriptor #63 Ljava/lang/String;
@com.google.gson.annotations.SerializedName(value="facebook_id")
protected java.lang.String facebookId;
// Field descriptor #63 Ljava/lang/String;
@com.google.gson.annotations.SerializedName(value="twitter_id")
protected java.lang.String twitterId;
// Field descriptor #82 Ljava/lang/Integer;
@com.google.gson.annotations.SerializedName(value="blob_id")
protected java.lang.Integer blobId;
// Field descriptor #63 Ljava/lang/String;
@com.google.gson.annotations.SerializedName(value="user_tags")
protected java.lang.String tags;
// Field descriptor #63 Ljava/lang/String;
protected java.lang.String password;
// Field descriptor #63 Ljava/lang/String;
protected java.lang.String oldPassword;
So we can see that for instance full_name can be saved fine with Gson but for instance login and email_address are not.
In comparison to QB iOS SDK, the QBUser class is implementing NSCoding into full extent which allows me to nicely store current user object to NSUserDefaults which is kind of the same as Android's SharedPreferences.
If this is not the correct way to store the user locally to the device, all tips are appreciated! :)