DROP table using Room persistence library

2.8k Views Asked by At

Is there any way to drop tables directly while using Room . I have tried the below code under DAO class @Query( "DROP TABLE IF EXISTS 'tablename'" ) void dropFavoriteShowEpisodeTable(); But I am unable to build and error is

UNKNOWN query type is not supported yet. You can use:DELETE, UPDATE, SELECT

I understand that during migration , I can directly drop tables using

database.execSQL( "DROP TABLE IF EXISTS 'tablename' );

But what if I want to drop a table at a later stage. How to achieve that ? Thanks in advance

1

There are 1 best solutions below

0
On

No Room doesn't support Drop at all. You need to delete all the records by using

DELETE * FROM TABLENAME