I need to use SQL VIEW in a query using the save space library.
Using Commonsware answer here I was able to run a raw SQL statement to create a view during database creation.
Room.databaseBuilder(context, MyDatabase.class, DB_NAME)
.addCallback(new RoomDatabase.Callback() {
@Override
public void onCreate(@NonNull SupportSQLiteDatabase db) {
super.onCreate(db);
db.execSQL("CREATE VIEW view_name " +
"AS SELECT [...] "
);
}
})
.build();
VIEW is actually created in SQLite DB and works fine, but I can't reference it in my Dao @Query because I get a compile-time error:
Error: (100, 48) error: there is a problem with the query: SQLID_ERROR] SQL error or missing database (no such table: output_name)
Any idea on how to let Room know about my view or ignore the error?
source
share