Kishan S. Rakholiya
Kishan S. Rakholiya

Reputation: 389

Data not persisted with Room Persistence Library while upgrading Database Version

When I upgrade my Database from Version 1 to Version 2 and insert new data then all old data stored in Version 1 of database were deleted and I can see only newly inserted data in database.

Any idea how to persist data while upgrading database with Room Library?

Upvotes: 1

Views: 1393

Answers (1)

Kishan S. Rakholiya
Kishan S. Rakholiya

Reputation: 389

I found solution from the same link. And when the migration class is not provided then Room Library deletes whole Database with data on onUpgrade() and create Database again.

It is compulsory to provide Migration class if you want to persist data on onUpgrade()

Upvotes: 1

Related Questions