I was using room in my android project, everything was working fine until one day I found Room doesn't insert data in db immediately.
How I reproduced it
When I run command appdatabase.getUserDao().insert(user) and after 2 seconds when i remove my battery from my phone and export db after that What I found is data is not inserted in db. that is 100% sure because my team has reproduced it multiple times. it seems instead of directly store into db it caches data for some time.
Is there any solution for it Where data will directly store in db instead it caches?
Yes, close the database before exporting:
RoomDatabase.close()
Make sure it is the
Room.databaseBuilder()
and not
Room.inMemoryDatabaseBuilder()
Check if the thread is executing properly and that you are not interrupting a @Transaction insert
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With