sqlite3 permission denied android

2019-03-25 03:36发布

I'm trying to access the database of the application I'm developping directly on my Nexus, but I get a "permission denied" when I tried to execute the "sqlite3" command. I also tried to start the adb in root mod, but again, permission denied on the device... I guess I will have to do that with the emulator but I have a lot of data to load and it would have been 10 times faster with the phone on Wifi than the emulator... Unless someone has any idea? thanks

4条回答
叼着烟拽天下
2楼-- · 2019-03-25 03:44

I struggled with this for a while, so here's my solution, which works on an unrooted device:

#!/bin/sh

# fill these values in
PACKAGE=com.example.android
DB=something.db 

# copy db to sdcard using package permission (using cat because no cp    command)
adb shell "run-as $PACKAGE cat /data/data/$PACKAGE/databases/$DB >   /sdcard/$DB"

# pull file from sd card
adb pull /sdcard/$DB

# do something with it (need to install sqlitebrowser obviously)
sqlitebrowser $DB
查看更多
\"骚年 ilove
3楼-- · 2019-03-25 03:48

I had a similar problem. I pulled sqlite3 from emulator and pushed in on my device and couldn't run it - permission denied.

Apparently sqlite3 binary didn't have execute permission (-rw-rw-rw-) so chmod +x sqlite3 solved the issue.

查看更多
Juvenile、少年°
4楼-- · 2019-03-25 04:03

The files are read protected, you need to root your phone or use the emulator.

查看更多
Juvenile、少年°
5楼-- · 2019-03-25 04:04

Typical.

I worked around this annoyance by adding a feature to my app that backs up (copies) the DB to the SD card. adb pull works against any sdcard files.

EDIT: fixed "adb" misspelling (was "sdp".

查看更多
登录 后发表回答