Room persistance library. Delete all

Sirelon picture Sirelon · May 29, 2017 · Viewed 109.1k times · Source

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 :)

Answer

yigit picture yigit · May 29, 2017

You can create a DAO method to do this.

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