Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
do you want to drop all tables or truncate all tables?
i think we can generate a method that does that in RoomDatabase.
i think we can generate a method that does that in RoomDatabase.
ta...@gmail.com <ta...@gmail.com> #3
I was also looking for this and could not find it. For me it would be ideal if it could drop the whole database. So when the user logs out everything is cleared and the new database is then created on a new log in - the same as if running the application for the first time.
yb...@google.com <yb...@google.com> #4
you can consider closing and then deleting the database. (context.deleteDatabase).
The only difference vs truncating would be the auto-increment ids would be reset. Is it that important?
The only difference vs truncating would be the auto-increment ids would be reset. Is it that important?
ta...@gmail.com <ta...@gmail.com> #5
I was looking for something like deleteDatabase in the documentation and could not find it. That would be perfect for me. I don't care about auto-increment ids resetting or not, but lets wait for the original poster to tell his/her wishes.
ec...@gmail.com <ec...@gmail.com> #6
Truncate makes more sense because my goal is to get rid of all the data on logout, although both options drop or truncate would work. I don't care much if tables are dropped neither about auto-increment ids resetting. In terms of performance which option is better?
ya...@google.com <ya...@google.com>
ak...@gmail.com <ak...@gmail.com> #7
You could also use `deleteDatabase(DB_NAME)` in your Activity where user is performing logout. This will delete the entire database.
PS: Make sure the DB_NAME is the same name passed to Room.
PS: Make sure the DB_NAME is the same name passed to Room.
Description
Version used: 1.0.0-alpha3
Devices/Android versions reproduced on: All
- When the user logs out from the app I want to delete all the data from the database.
Currently a workaround is to delete all data from each table, but this means every time a new table is added in a new version of the app, it must be added to the function in charge of deleting all tables.
Is there a way to write an SQL query in Room BD to drop all tables?