diff --git a/app/src/main/java/com/smarthomies/realtimetalk/database/UserDAO.java b/app/src/main/java/com/smarthomies/realtimetalk/database/UserDAO.java index 0626d76..3a01aff 100644 --- a/app/src/main/java/com/smarthomies/realtimetalk/database/UserDAO.java +++ b/app/src/main/java/com/smarthomies/realtimetalk/database/UserDAO.java @@ -15,7 +15,12 @@ public class UserDAO extends RealmDAO { } public User findUserById(Realm realm, int id) { - return realm.copyFromRealm(realm.where(entityClass).equalTo(User.PRIMARY_KEY, id).findFirst()); + User user = realm.where(entityClass).equalTo(User.PRIMARY_KEY, id).findFirst(); + if(user != null) { + return realm.copyFromRealm(user); + } else { + return null; + } } public void deleteById(Realm realm, int id) {