从模拟器中删除应用程序数据库
我正在测试我正在开发的一个应用程序,我想删除我的应用程序创建的数据库,以便我可以将网络服务器中的所有数据读回新的数据库。
我启动了 adb,转到 data/data/my.applicaton.package/databases 并执行了“rm mydatabase”。这删除了数据库(注意:我之前已经这样做过很多次了,没有出现问题)。
我再次启动我的应用程序,令我惊讶的是,没有创建新的数据库。更令人惊讶的是我的应用程序中有数据。我的应用程序仍在从某个地方提取数据!它从我的数据库获取 Cursor 并使用 CursorAdapter 来填充列表。所以,它显然是从一个数据库中读取的(似乎是一个缓存的数据库?)。
它到底是从哪里来的,为什么?它指向一个现已删除的数据库。
I'm testing an application I'm working on and I wanted to delete the database my application creates so I could read all the data from my web server back in to a fresh one.
I launched adb, went to data/data/my.applicaton.package/databases and did a "rm mydatabase". This deleted the database (note: I've done this many many times before without a problem).
I launched my application again and, to my surprise, a new database wasn't created. Even more surprising is there was data in my application. My application is still pulling the data from some where! It gets a Cursor from my database and uses a CursorAdapter to populate the list. So, it is obviously reading from a database (seemingly a cached one?).
Exactly where is it pulling from and why? It's pointed at a database that is now deleted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定您没有启动该应用程序,点击主页/返回进入主屏幕,然后您的 adb 魔法发挥了作用吗?如果您这样做,则程序仍在后台运行,并且无法正确获取对数据库的更改。在对数据库进行更改之前,您应该确保终止应用程序 DDMS 中正在运行的进程。然后启动应用程序并查看更改是否生效。
我多次遇到过这个问题。
Are you sure you hadn't started the app, hit home/back to get to main screen, then did your adb magic? If you did that, then the program was still running in the background and the changes to the database were not picked up correctly. You should make sure to kill the running process in DDMS of your application before making changes to the database. Then launch the application and see if the changes are picked up.
I've run into this issue many times.