SQLite 数据库副本在由设备而不是模拟器生成时出现损坏 [英] SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator

查看:27
本文介绍了SQLite 数据库副本在由设备而不是模拟器生成时出现损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我要感谢所有阅读本文的人.Stackoverflow 是一个了不起的网站,你们每天都以已经提交的问题的形式帮助我回答问题.你们都摇滚!

First I want to say thanks to everyone that reads this. Stackoverflow is an amazing site and you guys help me out with answers everyday in the form of questions already submitted. You all rock!

我的问题:

我正在开发一个数据库应用程序,我想在某些点备份数据库,以便在开发过程中随着时间的推移将收集到的数据保存在数据库中.因此,为了将数据库保存到可访问的内存中,我遵循了这个页面:

I'm working on a database app that I'd like to back up the database at certian points so I can save the data I've collected in database over time, during development. So to save the database to accessible memory I've followed this page:

如何从我的数据库中提取数据库android 到我的桌面?

..上面的代码在模拟器中运行良好(我可以使用 DDMS 将数据库的副本拉到我的 PC 并使用 SQLite 数据库浏览器查看它).但是,当我在实际设备上运行它时,SQLite 数据库浏览器无法读取它.推断,副本在 SD 卡上创建得很好,但是当我从我的设备复制到我的 PC 并查看它时,我什么也没得到,SDB 无法理解它或其他东西.但是,当我使用模拟器时,我可以使用 DDMS 将其复制下来,并使用 SDB 很好地查看所有表.

..and the above code is working great in the emulator (I can use DDMS to pull the copy of the database to my PC and view it using SQLite Database Browser). However when I run it on an actual device, SQLite Database Browser can't read it. To extrapolate, the copy is being created just fine on the SD card, but when I copy to my PC from my device and view it, I get nothing, SDB can't understand it or something. However when I use an emulator, I can copy it off using DDMS and view all the tables just fine with SDB.

使用 WinMerge 比较两个原始数据库文件(一个由设备生成,一个由运行相同代码的模拟器生成)我可以看到存在格式差异,但看起来没有任何损坏,但我不是 100% 当然.android 元数据和 SQL 序列表似乎在其中(尽管顺序不同),以及我的自定义表.

Using WinMerge to compare the two raw database files (one generated by the device, one generated by the emulator both running the same code) I can see there are formatting differences, but nothing that looks corrupted, but I'm not 100% sure. The android metadata and SQL sequence tables appear to be in there (albeit in different orders), as well as my custom table.

你们对如何调试有什么建议吗?我不确定从哪里开始,因为它似乎在模拟器上完美运行.此外,我在与设备相同的 android 版本 (2.3.3) 上运行模拟器,所以我非常确定他们使用的是相同的 SQLite 引擎.

Do you guys have any suggestions on how to debug this? I'm not sure where to start since it seems to work perfectly on the emulator. Also, I've run the emulator at the same android release (2.3.3) as the device, so I'm am pretty sure they are using the same SQLite engine.

谢谢,马特

推荐答案

我会尝试用不同的 SQLite 打开这个数据库 客户端.

I'd try opening this database with different SQLite clients.

如果这不起作用,下一步可能是尝试查找 SQLite 数据库文件 验证器和/或在调试模式下运行标准 SQLite 客户端(但老实说,我什至不知道最后两个选项是否可行).

If that doesn't work, the next step may be to try finding an SQLite database file validator and/or to run the standard SQLite client in debug mode (but to be honest, I don't even know if those two last options are even possible).

这篇关于SQLite 数据库副本在由设备而不是模拟器生成时出现损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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