05/05/2019, 3:59 PM
Is anyone aware of an open source project of a class that wraps a java.sql.Connection and implements SupportSqliteDatabase (or related AndroidX interfaces)?

Cody Engel

05/05/2019, 4:01 PM
Not off the top of my head. This does sound similar to what Room or SQL Delight aim to offer (fairly thin layer over top of SQLite). What are you looking to do?


05/05/2019, 4:18 PM
In tests, I want to provide a SQLite connection that looks like SupportSQLiteDatabase but doesn’t require an Android Context. SQLDelight is the library I’m using actually, and I’m using the AndroidSqliteDriver. That library has a JDBC driver, but they’re quite different in practice (specifically related to caching, which I realize even in my proposed scenario the SupportSQLiteDatabase implementation would have to simulate/mimic behavior/implementation). The other piece to this puzzle is that I want to use a SQLite compiled with json1, which is easy to do in Android (requery/sqlite-android), but in unit tests loading that .so is difficult/impossible but is doable using other jvm/JDBC based distributions. With a SupportSQLiteDatabase wrapper, I can have AndroidSqliteDatabase use the JDBC connection in tests
In the interim, I've decided that using xerial's JDBC in tests, which at least allows me to use a modern sqlite with the compiled in options I want. Writing the SupportSQLiteDatabase wrapper around that seems like the effort != benefit, at least for now.