Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ViewModel with SQLite database and not Room database

Tags:

android

sqlite

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?
like image 373
Urchboy Avatar asked Sep 17 '25 23:09

Urchboy


1 Answers

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.

like image 66
CommonsWare Avatar answered Sep 19 '25 14:09

CommonsWare