Does Roomdb Supports Dropalltables() And Createalltables()?
GreenDAO supports DaoMaster.dropAllTables() and DaoMaster.createAllTables(). I'm looking for similar functionality in RoomDB. Does RoomDB supports this functionality ?? The use-cas
Solution 1:
Room supports dropping and creating tables only during a migration between schema versions.
You can gain access to the underlying SupportSQLiteDatabase
via RoomDatabase.getOpenHelper().getReadableDatabase(). With that, you can use execSQL() to execute SQL statements, include table dropping and creating.
But doing so is not consistent with the intended use of Room and is not safe. It will very likely break the InvalidationTracker used to notify observers of changes to managed tables.
From your use-case, it seems like rather than dropping and recreating the tables, all you need to do is clear them by deleting all entries.
Post a Comment for "Does Roomdb Supports Dropalltables() And Createalltables()?"