-->

“Invalid file format” from device pulled *.db file

2019-03-01 07:06发布

问题:

I'm learning Android developement. And I receive always this error while opening a pulled database file from device: "Invalid file format"

I use this commands to pull the

adb shell "run-as package chmod 666 /data/data/package/files/database"
adb exec-out run-as package cat files/database > C://test/database

I thik, the file size is correct, and when I open it in with a text editor I can read the content, with special characters, of course. But the sqliteBrowser can't read it.

回答1:

I had a same problem with android 4.2, although I used ubuntu 16.04 and sqlite browser instead.

I found only one way that I could access my not rooted phone's file system and finally I could open the database file.

Install SSHDroid on your phone

adb -d shell "run-as your.package.name cat databases/database_name.db > /mnt/sdcard/database_name.db"

just for sure, you can check whether the file is there

$ adb shell
shell@android:/ $ cd /mnt/sdcard
shell@android:/mnt/sdcard $ ls

if you don't know the exact name of your package then

adb shell 'pm list packages -f'

start the SSHDroid

the default username is root and the default password is admin. It makes sense to change the password.

start FileZilla
open the Site Manager and add a new site with the settings of the SSHDroid's ssh server.

set /mnt/sdcard as default remote directory

and connect to your phone via SFTP protocol