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 d
You can create a DAO method to do this.
@Dao
interface MyDao {
@Query("DELETE FROM myTableName")
public void nukeTable();
}
To make use of the Room without abuse of the @Query
annotation first use @Query
to select all rows and put them in a list, for example:
@Query("SELECT * FROM your_class_table")
List`<`your_class`>` load_all_your_class();
Put his list into the delete annotation, for example:
@Delete
void deleteAllOfYourTable(List`<`your_class`>` your_class_list);