As you know we can select from multiple databases using attach command like this:
String path = DBHelper.getDatabasePath(context);
String sql = \"ATTACH DATA
While building room database using the DatabaseBuilder class, you have an option to register a callback which has methods that'd be called everytime your database is opened:
/**
* Called when the database has been opened.
*
* @param db The database.
*/
public void onOpen(@NonNull SupportSQLiteDatabase db) {
}
One option is to register this callback and ATTACH
your other database using the db
parameter. Then in dao, you can have queries which reference the other table.