开发者

watching sqlite db on device

When i de开发者_C百科bug my android application on emulator i can connect to it with adb shell and view my database file with sqlite3 command. But on real device i can't do this because i haven't root permissions. There are any way to do this?


If you are working with Eclipse try this out: questoidsqlitemanager.


It's an operating system-level permissions issue, so you either have to move the database to someplace with more relaxed permissions (not sure if the api will let you put it on the sdcard, though underlying libraries should).

Or else you could do the database monitoring from something that has permission to read there, which is to say something running as root or more likely as the app_## user id created for the application upon installation. For example - and this is not something you should do except on your device for testing - you could make a copy of the toolbox shell someplace accessible for writing and executing (like that /sqlite_stmt_journals directory) and make it setuid your application's user id (your application itself will have to do the copying and chmod'ing programmatically). Then you can run that shell from the adb shell and become the application's user id.

Or any process started programmatically by the application will have it's user id, so you could also read up on running netcat ("nc", I think even packaged in the official android builds) in it's mini-insecure-telnet-daemon mode and launch that from your application so that if you use adb shell or an adb port forward to connect to the port where it's listening you'll get a shell running as the application user id.

Or you could build database exploration functionality into your application, either listening on tcp or using a file watcher as a trigger and dumping a file on the sd card that you can examine.

Or you could root your phone.


Your database file must be in /data/data/YOUR_PACKAGE_NAME/databases, try this :

adb shell (Use "-s" option if you have more than one device)
sqlite3  /data/data/YOUR_PACKAGE_NAME/databases/YOUR_DATABASE_NAME

move YOUR_DATABASE_NAME into /DATA folder change the right (chmod 777 YOUR_DATABASE_NAME). And now you will able to get the file. Now you can use sqlite3 or SQLite Manager plugin.

You can root with Superuser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜