Reputation: 926
This question can be the solution to a few but trying to discuss the drawback here.
I have a project in which I use ROOM for caching the server response. Although it's one of several techniques to cache the data, instead of worrying about the best way of doing something I felt let's start(as I need to query the specific stored data to display) and built the whole project on ROOM as caching technique. What I'm doing currently,
First Call,
Subsequent call where cache data is available,
I definitely agree the above logic works perfectly to most of the scenarios for many.
But there is still a drawback here. At this point, my project has become huge, and every data shown is dependent on ROOM DB. Every release I do has some or the other change in the table for which I need to write a migration. Now my app users are spread across 5 to 6 different versions of the app. The maintainability of the app is getting costlier.
My question is,
I hope I was able to explain my problem, thanks for your time on my issue.
Upvotes: 1
Views: 2490
Reputation: 166
I am not sure if this would be really helpful.. But if you say that your table structure keeps on changing frequently then maybe instead of using ROOM or SQLite for caching you can consider writing the data(assuming its JSON) in a file in cache folder of your app and reading from it.. Android does provide us with a cache folder where we can create temp files etc so this way, if there is any change in the structure, you will not have to worry about migrations as the data will be written in the file and read from it directly. So, changes in your model would suffice for this requirement. This would become similar to NoSQL but I am not sure android supports NoSQL natively. There is also not very significant lag or processing time involved in this file read/write method.. But if you want to use the ROOM persistence library then yes you will have to handle migrations for every change in the structure..
Upvotes: 1