I searched and found FindFirst returns a null question, but no one answered it. Since I think I'm doing something wrong, let me explain my problem in more detail.
I am working on an application that asks the user to log in first and then allow the user to use the application.
My User class is as follows:
public class User extends RealmObject { @PrimaryKey @SerializedName("uid") String id; @SerializedName("ufname") String firstName; @SerializedName("ulname") String lastName; String avatar; int sessions; int invites; String nextSessionTime; String nextSessionTitle; @SerializedName("lastlogin") String lastLogin; String token; @Override public String toString() { return new GsonBuilder().create().toJson(this, User.class); }
I save the User object in Realm db after successfully entering the SigninActivity class:
@Override public void onSignInResponse(final GeneralResponse response) { if (response == null) { Timber.e("response is null"); return; } Timber.d(response.toString()); if (response.isSuccess()) { // Store user info including Token realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { realm.copyToRealmOrUpdate(response.getUser()); } }); // Goto main screen MainVideoActivity.startActivity(this); this.finish(); } else { String errorMessage = response.getErrorMessages(); super.displayMessage(errorMessage); } }
After a successful login, the application directs the user to MainVideoActivity . I want to find the user in the area, following the code, but I get null .
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_video);
User null in both approaches.

However, I do not see my user null in db.

I use the classpath "io.realm:realm-gradle-plugin:2.0.2"
Hesam source share