Urchboy
Urchboy

Reputation: 865

Using ViewModel with SQLite database and not Room database

I have a major concern. I just read about the android ViewModel as a better alternative to surviving orientation changes in android and a way to reduce boilerplate codes. I have an existing project done with SQLite and LoaderManager and would like to migrate from the use of Loaders to ViewModel. However all the tutorials and docs I find online always uses ViewModel with Room Library.

I cant afford to start learning Room and my project will be very difficult to refactor in order to support Room.

Hence goes my question:

  1. Can I use raw SQLite with ViewModel?
  2. Was ViewModel designed to work only with Room database?

Upvotes: 4

Views: 1412

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006944

Can I use raw SQLite with ViewModel?

Yes, as ViewModel has nothing to do with any particular source of data.

Was ViewModel designed to work only with Room database?

No. They are completely independent.

Upvotes: 5

Related Questions