Search code examples
androidrealm

Android Realm migration without losing the real users data


SO I'm migrating the realm database of my old app.

in the previous version, we didn't specify version number or name.

how can I know these data ? and please provide me with a way to check that data will not be lost . Also if I just change the way I query and add save data without changing the model , do I need to migrate ?


Solution

  • Migration is mandatory if you change anything in a RealmObject like add/remove field, change a type, add constraints.

    You can use migration to migrate only your data.

    If you change your queries (select, insert, update, delete), no migration is needed.

    You can check Realm documentation, it's pretty clear : https://realm.io/docs/java/latest/#migrations