Android Realm Migration version number based on what? -


i'm doing first realm migration , started thinking version number. on version number based?

because if based on over phone, how handle if new person installs app , gets migration? because update fields set because of fresh install.

christian realm here. migration api still in experimental state , kinda ugly, right version number start 0, , way changing through migration.

this means if want fresh install different version other 0, have like:

   // pseudo code     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; // set version numbers                             }                         })                 prefs.edit().putboolean("versionset", true).apply();             }              return realm.getinstance();         }     } 

this going lot better though: https://github.com/realm/realm-java/pull/929


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -