Hi folks, I have questions about migrating from Ro...
# multiplatform
c
Hi folks, I have questions about migrating from Room to SQLDelight. In our app, we have more than 30 tables using Room 1. Can we adopt SQLDelight incrementally ? 2. Can Room and SQLDelight be used together in the same app and pointing to the same database ?
j
Both should be possible, although you'll have some duplication that you'll have to manually keep in sync by using both libraries
c
Thanks @jw for answering. Btw I played a bit with it by creating 1
.sq
file for one of my tables (created by Room) and implement
GET
query. I was successfully able to get the data using SQLDelight, even when the table and the data inside it are created & stored using Room library.
But I'm curious about my Logcat, I got this error & warning message when everything seems to be fine
Copy code
SQLiteLog E  (5) statement aborts at 1: [PRAGMA journal_mode=TRUNCATE] database is locked

SQLiteConnection W  Could not change the database journal mode of '/data/user/0/xxxx/databases/xxxx.room.database' from 'wal' to 'TRUNCATE' because the database is locked.  This usually means that there are other open connections to the database which prevents the database from enabling or disabling write-ahead logging mode.  Proceeding without changing the journal mode
j
Sounds like the way you have it setup that both libraries are opening their own database. What you need to do instead is have a single library open the database and then pass the reference to the other library. I know SQLDelight can accept a database instance without needing to be responsible for opening it. I have no idea if Room can.
c
Thanks for the help Jake, I was finally able to get rid of the error & warning messages by passing the
SupportSQLiteOpenHelper
from Room to SQLDelight Driver 👍 👍 👍
j
Excellent!