My Android app has a SQLite database and content provider. This content provider is registered in the AndroidManifest.xml application. It is not exported, so only my application can see it.
As part of resetting the user profile, I want to completely erase this database and recreate it from scratch. First I tried to call deleteDatabase() from the activity context. This works, but only if the application is closed and reopens. Otherwise, it will work when I try to insert lines saying that the database is read-only. My understanding is that the connection must be closed before calling deleteDatabase() . However, the connection is managed by the Content Provider and should not be closed manually, as I understand it.
As an alternative, I use the call() method from ContentResolver to call a custom function that will delete all the data in the tables and reset the sequence will be counted manually.
This works, but now I need to manually delete the data from each table and you have to keep track of any changes that I make in the future.
Is there a better way to delete the entire database and have the DatabaseHelper ( SQLiteOpenHelper ) trigger SQLiteOpenHelper () when using ContentProvider ?
source share