SQLite数据库副本出现损坏当设备而不是模拟器生成模拟器、副本、而不是、数据库

2023-09-07 16:27:07 作者:人间唯你值得

首先,我想说感谢大家读这一点。计算器是一个了不起的网站,你们帮助我解答每天在已经提交的问题的形式。你所有的摇滚!

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!

我的问题:

我工作的一个数据库应用程序,我想备份的数据库在certian点,这样我就可以救我已经收集到数据库中的数据随着时间的推移,在开发过程中。因此,为了节省数据库访问的内存,我跟着这个页面:

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:

How我拉过我的Andr​​oid数据库到我的桌面?

..和上面的code是伟大的工作,在模拟器(我可以使用DDMS拉数据库的副本到我的电脑,并查看其使用SQLite数据库浏览器)。然而,当我在实际设备上运行它,SQLite数据库浏览器无法读取。要举一反三,副本正在创建就好了SD卡上,但是当我复制到我的电脑从我的设备,并查看它,我什么也没得到,SDB无法理解什么的。然而,当我使用仿真器,我可以使用DDMS复制其关闭,并查看与深圳发展银行所有表就好了。

..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来比较两个原始数据库文件(一个由设备生成,一个仿真器产生都运行相同的code)我可以看到有格式的差异,但没有什么看起来损坏,但我中号不是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)的设备,所以我上午的 pretty的确认的,他们使用的是相同的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打开这个数据库clients.

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).