Error in copying user = realm.copyFromRealm(user); He clearly has nothing to copy. And please explain what the problem is. Maybe I do not correctly take data from realm?
Intent intent = getIntent(); username = intent.getStringExtra("username"); Realm realm = Realm.getDefaultInstance(); user = realm.where(User.class).equalTo("username", username).findFirst(); user = realm.copyFromRealm(user); realm.close(); FATAL EXCEPTION: main Process: com.happ, PID: 1138 java.lang.RuntimeException: Unable to start activity ComponentInfo {com.happ / com.happ.controllers.UserActivity}: java.lang.IllegalArgumentException: Null objects can be copied from Realm. at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2184) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2233) at android.app.ActivityThread.access $ 800 (ActivityThread.java:135) at android.app .ActivityThread $ H.handleMessage (ActivityThread.java:1196) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:136) at android.app.ActivityThread. main (ActivityThread.java Lower001) at java.lang.reflect.Method.invokeNative (Native Method) at java.lang.reflect.Method.invoke (Method.java sources15) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:601) at dalvik.system.NativeStart.main (Native Method) Caused by: java.lang.IllegalArmentment.main (Native Method) Null objects cannot be copied from Realm. at io.realm.Realm.checkValidObjectForDetach (Realm.java:1300) at io.realm.Realm.copyFromRealm (Realm.java:1013) at io.realm.Realm.copyFromRealm (Realm.java:987) at com.happ. controllers.UserActivity.onCreate (UserActivity.java:52) at android.app.Activity.performCreate (Activity.javaCl2231) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2233) at android.app.ActivityThread.access $ 800 (ActivityThread.java:135) at android.app.ActivityThread $ H.handleMessage (ActivityThread .java: 1196) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:136) at android.app.ActivityThread.main (ActivityThread.java Zn001) at java.lang.reflect.Method.invokeNative (Native Method) at java.lang.reflect.Method.invoke (Method.java.ln15) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.jav a: 785) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:601) at dalvik.system.NativeStart.main (Native Method)
copyFromRealm()method retrieves the model object that will be unbound from the database. Changes in this model will not lead to changes in the records in the database itself (changes in the records obtained through thewhere()method lead to changes in the database itself). Read a little about it - pavlofff