Best practice for session data
Hi,
I need some tipps/suggestion/ideas about how to use Realm in combination with session data. The user can edit data which are loaded from Realm. The changes the user has just made should be recovered after a configuration change of the device and only stored when he clicks on the save/done button.
Currently i copy all from the Realm objects to parcelable objects with the same structure. Changes are only be done on the parcelable objects. When a config change happens the session data is passed as argument to the onSaveInstanceState method....
I would like to avoid copying from and to Realm objects and the usage of disposable (parceable) objects. So what would be the best strategy to these kind of session data?
If you don't want to copy data to another object there is a few scenarios you can use:
- Save the RealmObject in a static variable instead of a Bundle
- Save the RealmObject inside Realm with a added tmp or unsaved boolean which you can check.
Neither is perfect, but we are currently evaluating how to best support Parcelable, so hopefully we can soon provide a solution.
Hi @petersnoopy I assume you got your question answered. Feel free to add additional information if this is not the case.
Hi @cmelchior I have a related question:
I would like to save also RealmObjects (to be more specific some RealmResults