I'm confused about these versions.
In document:
newVersion - the schema version of the Realm after executing the migration.
schemaVersion(long schemaVersion) - Sets the schema version of the Realm.
Is schemaVersion will be newVersion and why do we need ++oldVersion when migrate?
Migration Example
oldVersion is the version of the Realm file when starting the migration. New version is the expected version when done with the migration, which is equal to the number you provide in schemaVersion().
The reason for doing oldVersion++ is that it is an easy way of doing stepwise migrations that will work no matter which version you upgrade from. The code will automatically skip the steps not needed.
You can read more about migrations here as well: https://realm.io/docs/java/latest/#migrations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With