Search code examples
androidandroid-room

How to drop a Room database?


How can I delete the Room database of my app? I've found the clearAllTables() method, but that's not what I want. Instead I really want to delete the database on user logout and start all over.


Solution

  • Step #1: Call close() on your RoomDatabase. That should coalesce the contents of the wal and shm files into the main SQLite database file, leaving you only one file to delete.

    Step #2: Delete that database file. If you stored it in the default location, you can call deleteDatabase() on a Context.