Kingdom Christian is here. The migration API is still in a very experimental state and looks pretty ugly, so now the version number always starts at 0, and the only way to change this is to migrate.
, , 0, - :
public class RealmHelper() {
private static SharedPreferences prefs;
public static Realm getInstance() {
if (!prefs.getBoolean("versionSet", false)) {
String path = new File(context.getFilesDir(), Realm.DEFAULT_REALM_NAME).getAbsolutePath();
Realm.migrateRealmAtPath(path, new RealmMigration() {
@Override
public long execute(Realm realm, long version) {
return 42;
}
})
prefs.edit().putBoolean("versionSet", true).apply();
}
return Realm.getInstance();
}
}
: https://github.com/realm/realm-java/pull/929