ContentProvider的数据库没有被清除 [英] ContentProvider Database not getting deleted

查看:435
本文介绍了ContentProvider的数据库没有被清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发存储在SQLite数据库其数据内容提供商。在开发过程中,我需要改变模式,或者完全删除数据库并重建它(我不是在升级这个发展阶段的数据库)。

I'm developing a content provider which stores its data in an SQLite database. During development, I need to change the schema, or delete the database entirely and have it rebuilt (I'm not upgrading the database at this stage of development).

我找到数据库文件,存放在/数据/数据​​//数据库/ app_db。当我把它给我的台式机,我可以用SqliteSpy看到它的内容,一切都很好。然而,当我删除它,它并不总是得到的真正的删除。虽然我不能看到DDMS或ADB文件,我的应用程序仍然看到它。

I found the database file, stored at /data/data//databases/app_db . When I pull it to my desktop machine, I can use SqliteSpy to see its content and all is well. However, when I delete it, it doesn't always get really deleted. Although I can't see the file in DDMS or ADB, my application still sees it.

我想确保我的应用程序和服务都没有,当我删除该文件,但它似乎并没有帮助。在大约一半的时候,我删除的文件,我需要重新启动模拟器它有效果。

I tried to make sure my application and service aren't up when I delete the file, but it doesn't seem to help. In about half the times I delete the file, I need to restart the emulator for it to have effect.

有什么能preventing被真正删除的文件?

What could be preventing the file from being really deleted?

伊泰。

推荐答案

我已经看到了这个问题太当在写我的的ContentProvider S单元测试。你需要确保你已经杀了托管的ContentProvider 使用该特定数据库文件的过程。而且,只有不是将其删除。

I've seen this issue too when was writing unit tests for my ContentProviders. You need to make sure you've killed the process that hosts ContentProvider that uses that specific database file. And only than delete it.

这篇关于ContentProvider的数据库没有被清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆