0

I'd like to know if such a method exits, so when the user installs an app actualization the database gets properly actualized.

I've found a way that although it can't always work, I think in practice it will never fail, which is the following:

Check if database version of installed app is higher than the version in a hidden file in the previous app, if so, actualize the database.

Write that file with the database version of installed app.

This way, only if the user were to manually remove the file and not the database would cause my solution to fail in its purpose.

Even then it would be better if there was something that works like onUpgrade() from SQLite in Realm.

Is what I'm mentioning possible?

user2638180
  • 1,013
  • 16
  • 37
  • 1
    The question is unclear - when you say upgrade, what does that mean. Upgrade the app? The Code? The schema? Something else? Realms are pretty stable over time and as you release new versions of your app, they would generally be able to read the same data. On the other hand, if your schema changes, that requires some additional work (maybe), or if you change to a much newer SDK. Please clarify the question and we'll take a look. – Jay Aug 12 '21 at 16:48
  • @Jay, I refer to do the same as onUpgrade on SQLite, reference here: https://thebhwgroup.com/blog/how-android-sqlite-onupgrade – user2638180 Aug 12 '21 at 16:54
  • 1
    Realm offers local [Migrations](https://docs.mongodb.com/realm/sdk/android/fundamentals/schema-versions-and-migrations/) to handle things like destructive schema changes (additive changes don't need a migration). If you are using sync, you would make the changes, delete the local data and then allow Realm to re-sync to the server, which will 'update' your local database. – Jay Aug 12 '21 at 16:59
  • @Jay, thanks I will check that. – user2638180 Aug 12 '21 at 17:04

0 Answers0