Android Room has method void clearAllTables()
and according to docs it makes the following:
Deletes all rows from all the tables that are registered to this database as
entities()
.This does NOT reset the auto-increment value generated by
autoGenerate()
.After deleting the rows, Room will set a WAL checkpoint and run VACUUM. This means that the data is completely erased. The space will be reclaimed by the system if the amount surpasses the threshold of database file size.
I checked it in my project and looks like db has no data after that call, but when I pulled *.db file from my device and opened it in sqlite viewer I've seen that all the data exists, the tables are filled and nothing has been erased. How can that be? I consider this as a potential flaw in my app. Please provide a reliable approach of cleaning room database
DELETE
statements for all your tables. – Leftwich