I have a situation where I want to hard reset my database using the Android Room. Using SQLiteOpenHelper, I could do this by writing a method to delete all tables and indexes, then manually call SQLiteOpenHelper.onCreate().
I know that I can access SupportSQLiteOpenHelperthrough the room and independently drop all the tables, but there seems to be no good way to start the rest process.
In addition, I know that I can delete every element from each table without dropping it, but that is not what I want. This will not reset the primary key automatically incrementing, so the "id" field of the new elements will not reset back to 1.
Thanks!
EDIT:
This is what I want to do arbitrarily at runtime.
EDIT 2:
This method should be supported, i.e. It does not require manual spelling of SQL that matches the behavior of the room. Ideally, there would be some way to get the SQL that Room generates, or an equivalent method SQLiteOpenHelper.onCreate(). Or anything else that solves this problem! :)
source
share