Android 如何从应用程序中删除数据库?

Android 如何从应用程序中删除数据库?,android,Android,当我在手机上运行应用程序时,会出现以下异常: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. 我知道我可以用这个方法 fallbackToDestructiveMigration 但是如果我使用它,

当我在手机上运行应用程序时,会出现以下异常:

Room cannot verify the data integrity. Looks like you've changed schema but 
forgot to update the version number. You can simply fix this by increasing the 
version number.
我知道我可以用这个方法

fallbackToDestructiveMigration
但是如果我使用它,那么永远不会调用回调“onCreate”(我需要调用它)

奇怪的是,即使我“清除应用程序的数据”(通过取消设置)并卸载应用程序,我也会收到消息。显然,数据库从未真正从手机中删除,因为我不断收到版本冲突

如何从手机中删除数据库


谢谢大家!

您只需在手机android系统设置中删除应用程序或删除应用程序数据即可。记住:

<manifest ... >
...
<application android:allowBackup="false" ... >
    ...
</application>

...

我这样做了,但令人惊讶的是,数据库似乎并没有被真正删除,手机会记住它,甚至在卸载应用程序后也会引发版本冲突。我不明白…您可以通过ADB检查您的数据库文件是否仍保存在手机中。还有一个
fallbackToDestructiveMigration()
方法,您可以在
Room.databaseBuilder()中设置该方法。
Edit:我很高兴能够帮助您:)