如何在 Android 中填充测试数据库?
我有一个扩展 ProviderTestCase2<> 的测试类。
我想用一些 .db 文件中的数据填充这个测试类数据库。
是否有一些特定的方法可以将某些 .db 文件推送到 ProviderTestCase2 的模拟上下文中?
否则哪种方式更容易从 .db 文件填充数据库?!
非常感谢!!
I have a test class that extends ProviderTestCase2<>.
I would like to populate this test class database with data from some .db files.
Is there some particular method to push some .db file into the Mock Context of a ProviderTestCase2?
Otherwise which way is the easier to populate the database from the .db file?!
Thank you very much!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 SD 卡或类似的东西复制预先存在的 .db 文件怎么样?这是一段快速的代码,可以为您完成此任务:
希望这适用于您的场景
How about copying in a pre-existing .db file from the SD Card or something similar? This is a quick piece of code that will accomplish this for you:
Hopefully this will work for your scenario