Search code examples
androidandroid-roomandroid-architecture-components

Room persistance library. Delete all


How can I delete all entries on specific table using Room Persistence Library? I need to drop table, but I cannot to find any information how to do this.

Only when database is migrating or to load all entries and delete them :)


Solution

  • You can create a DAO method to do this.

    @Dao 
    interface MyDao {
        @Query("DELETE FROM myTableName")
        public void nukeTable();
    }