In an app (Koin, Room and Datastore) I need to preload an assets sqlite .db file with Room each time the app is updated. This implies that the old cached version of the room database must be deleted and replaced by the assets .db file if a update of the app has been produced. It's a huge file, 1 MB. I did two approaches and counted the time in ms that took each one:
Approach 1: Using Datastore to read/save the version of the app when the database was cached and only delete/preload the database again if the app has been updated. If not, simply load the cached database
Approach 2: Delete the cached database on each app start and preload it again, avoiding Datastore usage on app initialization. This means deleting and writting 1 MB of data always on the cache of the app.
Result: Approach 1 took around 300ms to delete/preload database if an update of the app has been detected, and 190-200 ms to check the version and continue without deleting it if the app has not ben updated, I mean, if it's a normal start. Simply loading the cached one.
On the other hand, approach 2 takes only 20-30 ms on each app start to delete/preload the database. How can be faster to do it in the inneficient way? It seems that datastore is very slow. Now I'm wondering what option should I use. To make the user wait on app start, or to erase and write 1MB of data on each app start. What do you think? which option whould you select and why?