2

I need to copy the database from phones which is without "Root“ to pads. So I also adopt the method like others: copy /data/data/../databases/test.db to /sdcard at first. And then I use adb shell sqlite3 command in my PC or in my friends' PC, there are some question: 1) sometimes, it can open successfully 2)sometimes,it show "file is encrypted or is not a database" 3) sometimes, it show "database disk image is malformed"

Note: the sqlite3 version are different.

the root cause of "file is encrypted or is not a database" is the version problem, is it right?

what is the root cause "database disk image is malformed"? I search some information about it on internet, but I can't still fix it.

Thanks!

Edit 1:The test phone is HTC HD Edit 2: I this thread: http://groups.google.com/group/android-developers/browse_thread/thread/2b8a8fa9b955eecd/0615c6111d93ea02?lnk=raot There are message: I would very strongly advise you against doing this. There is no guarantee that the binary database file will be compatible across Android version and much less across all custom ROMs.

It seems the root cause of "database disk image is malformed" is the Sqlite3 version. But how to backup the database to sdcard is best way? Are there another ways?

Edit 3: link 1 link 2 link 3

Community
  • 1
  • 1
Judy
  • 1,772
  • 6
  • 27
  • 48
  • in the thread you linked, there are many posts about the database file not being copied properly –  Apr 19 '12 at 09:32

1 Answers1

0

My instinct is to think that the database file becomes corrupted somehow during the transfer. From my experience, if a database file is corrupted, it's done for.

You should verify that the database file is not corrupted on both the source and the destination with the following pragma:

PRAGMA integrity_check; 

If all is good, the result set is a single column record with the value ok.

Just to be clear, for any of the following three scenarios, your database is pretty much corrupted and unusable:

  • sqlite3 won't even open the database file and return some error
  • sqlite3 will open the database file, but return some error when you run some statements
  • sqlite3 will open the database file, but pragma integrity_check doesn't return ok

Since both your source and destination seem to be using sqlite 3.x.y.z, the file format shouldn't be an issue (there are a few exceptions, but I doubt any of them are the source of your pain).

Another thing you probably want to do is to verify that the files are identical at the source and destination. You can compare their hashes (md5, sha1, or others).