简体   繁体   English

使用 Nougat 从 nexus 5X 中删除数据库

[英]Removing database from nexus 5X with Nougat

I am testing my app on my nexus 5x.我正在我的 nexus 5x 上测试我的应用程序。 I thought, but am not sure, when I opened DDMS in android studio I could look at and remove files in the private files section.我想,但不确定,当我在 android studio 中打开 DDMS 时,我可以查看并删除私有文件部分中的文件。 Now my phone is updated to Nougat and I can no longer see any files on the device, be it in the private section or in the public one.现在我的手机更新为牛轧糖,我再也看不到设备上的任何文件,无论是在私人部分还是在公共部分。

Furthermore I made some changes to the database and thought removing the old app would remove the old database.此外,我对数据库进行了一些更改,并认为删除旧应用程序会删除旧数据库。 After installing and running the new version I am getting an error reporting the database is missing a table.安装并运行新版本后,我收到一条错误消息,报告数据库缺少表。 Apparently my old database is not deleted by uninstalling the app, as this table is added in the new version on creating the database.显然,卸载应用程序不会删除我的旧数据库,因为该表是在创建数据库时添加到新版本中的。 Already tried removing data and then removing the app.已经尝试删除数据,然后删除应用程序。

Any idea how to delete the old database or how to access the private files section?知道如何删除旧数据库或如何访问私有文件部分吗? Not directly an programming question so if there is a better place to post the question I apologize.不是直接的编程问题,因此如果有更好的地方可以发布问题,我深表歉意。

to answer my own question.回答我自己的问题。 I found this我发现了这个

And finally... calling adb uninstall [yourpackagename] ........ totally uninstalls the app.最后...调用 adb uninstall [yourpackagename] ........ 完全卸载该应用程序。

A same command is available from inside android studio. android studio 中也提供了相同的命令。 Under the Run menu there is the command Clean and Rerun.在运行菜单下有命令清理和重新运行。 This cleans out the database on the testdevice, so no need to update the database version during development.这会清除测试设备上的数据库,因此无需在开发过程中更新数据库版本。

Firstly .. You should not remove database before impl migration to newer DB scheme version.首先..在impl迁移到较新的数据库方案版本之前,您不应该删除数据库。 Safest way is to increment DB version .最安全的方法是增加 DB version 。 so it does not matter whether you have old or not.所以不管你有没有老。

Secondly .. Take a look on this how to remove shared preference while application uninstall in android .其次..看看这个如何在android中卸载应用程序时删除共享首选项 You may face the same issue that backup stored old db and restores again after installing newer version.您可能会遇到备份存储旧数据库并在安装新版本后再次恢复的相同问题。

Simply try to set this into manifest at least for debug:只需尝试将其设置为至少用于调试的清单:

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

It will prevent to restore any thing back from cloud.它将阻止从云中恢复任何东西。

Thats why I mentioned its better to track version of DB than just updating content.这就是为什么我提到跟踪数据库版本比仅仅更新内容更好的原因。

I hope that may help you,'.我希望这可以帮助你,'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM