Realm databases and compatibility between different schemas - android

I am creating Android app and need a way to store data and sync with server so i have posibility to have access to the same data from different devices and places. I am consider using Realm Database. I think that it will match all my requirements. But i have one question. Let assume that we released version 1.0 of our application, few users have access to one realm (lets name it REALM-ONE), they are making changes there(insert, update, delete). In meanwhile we developed a next version of our app with a little changed schema, i mean we add one property to the object and make a breaking changes in another(e.g. merge two properties into one and change data type). Part of the REALM-ONE users updated app to the newest version(other users cannot because of too old version of android), and i want everyone to have opportunity to still using the REALM-ONE as before without need to update app. Quick diagram:
According to docs i know what will happen with new property, it will update on server and be visible in v2.0 but surely should not be visible for previous version of the app. And what with breaking changes ? Can i support this change in v1.0 ? Can it still collaborate together ? Can I managed it with realm notifications or realm functions ?

Related

Instrumentation Testing Room migrations

We have a project that extensively uses offline storage hence Room. The database has been migrated so many times that It is currently on V77.
we are planning to incorporate migration testing now ( I know it is too late ) hence want to write test for migration fron v77 to v78.
I wanted to know what is the best way to write tests for this scenario , The database is huge and complex containing joins etc.
I tried following the articles on Room migration tests but it is only for a small schema.
Also the Room generated schema jsons have been limited , would that be an issue for this ? and is there a way to generate the previous versions like 1.json etc.
I have followed the online medium articles precisely like it has been implemented and has been getting errors when migration happens on database joins etc.
Then I tried to follow the Android Doc for testing migrations but since I dont have the json files for pervious versions , I cannot implement that.
Can anyone suggest a good repo or already implemented tests for a similiar use case
Thanks .
and is there a way to generate the previous versions like 1.json etc.
yes, you can change the code for the previous version(s) so that in the #Database annotation exportSchema = true is coded AND that the room.schemaLocation is set accordingly (and obviously that the version number is set accordingly). You can the compile the project and the schema for that version will be generated.
Obviously due to the above changes the version being compiled is not exactly the same. However, the schema should be exactly as required as long as no other changes have been made that affect the schema.

how BoxStoreBuilder.usePreviousCommit works internally?

i converted my android app from mapdb to objectbox, i've seen on github a few people reporting database corruption with objectbox and the solution has always been to call usePreviousCommit in case of problems.
since the objectbox core is close source I wanted to know what usePreviousCommit does internally
are there 2 physical copies of the database? and calling usePreviousCommit reverts to the previous copy?
or does it work in a more complex way? (if yes i wanted to know how)
i opened this question because i want more information from objectbox before i continue to use it in production.
The key word is multiversion-concurrency. Think of a B+ tree with copy-on-write. The previous root tree (aka the previous commit) is preserved, so you can use when opening.

Realm.io database, Does it work on ChromeOS's app runtime?

So I am planning to use a database called realm for a new android app, but before I choose this as the data layer I need to know if it plays nice with the app runtime for chrome(ARC). Does anyone know if they are compatible?
Update:12/21/2015
I recently asked if there where plans to support realm on arc in the near future and the answer was no.
https://github.com/realm/realm-java/issues/1011
Realm is currently not compatible with ARC. There is a feature request here you can follow for updates: https://github.com/realm/realm-java/issues/1011

Reuse a database from an old version

I'm about to completely refresh my app. I made it with ADT, ActionbarSherlock and SlidingMenu, and I am switching to Android Studio with Appcompat and Nav Drawer (as you see, a total change). This means that I'm doing it from scratch, and only reusing the calculation classes and a couple of layouts.
In fact, my plan is to switch from only offline database storage to offline database with an optional cloud synchronization. There will definitely be be changes regarding database (just a global online id and an author id).
Now, my question is, is there a procedure to avoid losing the information (both database and app private folders) of my app? I added the same package name, the version is add to the previous one, and is signed with the same key.
If your app is updated through the Play Store, then the existing databases / SharedPreferences will remain.

Managing an Android database

I'm looking to implement my first Android database, but I have so many questions which (I believe) are unanswered by all the tutorials I find.
Here are my needs:
- I want my application to have a database that is persistent. If my application closes and launches again, there is already a database to pull data from. It does not create a new database every time the application is killed and re-launched.
- I want to implement versioning. Say version 1 of my application has a few tables. I release version 2 and I want some sort of script to run to add new tables I've added or modify old tables I've added; and so on and so forth. The application has to know whether the database is at a particular version (which means I'll need a table in the database) so it knows whether to run this script.
Could someone provide me with some resources so I can figure out how to do what I need? Thank you
Look for sqlite+android+tutorial:
http://www.hdelossantos.com/2009/12/23/creating-a-sqlite-database-in-android/
http://www.hdelossantos.com/2010/01/07/using-a-sqlite-database-in-android/
and some more:
http://www.google.com.hk/search?sourceid=chrome&ie=UTF-8&q=android+sqlite+tutorial
There is also a sample in the sample programs that come with the SDK, i.e. the Notepad app.
And the official developer api doc - but that's more as a reference, not as tutorial:
http://developer.android.com/reference/android/database/sqlite/package-summary.html

Categories

Resources