Can't open data directory on rooted android phone [closed]
Want to improve this question? Update the question so it fo开发者_C百科cuses on one problem only by editing this post.
Closed 2 years ago.
Improve this questionI just rooted my phone because I need acces to the database my application is using. However, even though my phone is rooted, I still can't open the data folder in Eclipse File Explorer.
Is there something I've forgotten? Do I need to tell Eclipse I'm a superuser or something? I can access the data folder on the emulator, but not on my actual device.
And I really want to develop on my device, the emulator is much slower and I can't get the internet connection to work.
Any ideas?
In current versions of Android you don't need to do this. Just put android:debuggable="true" in your manifest and then you can use the shell's "run-as <package_name>" to switch to the uid of your application so you can access its data directory.
This definitely works on 2.3 or later; it might work on 2.2 I don't remember exactly when it went in.
Yet another option is to check the database using Root Explorer from the device itself. It can read .db
files. If you need to modify them, there is SQLite editor (by the same company), but I do not have much experience with it.
Update: I was playing with my phone after reaching this page: http://www.screaming-penguin.com/node/7742
Instead of the emulator as in that post, I had my phone connected to the usb (Samsung Captivate, custom 2.2 ROM), with usb debugging enabled.
I run the following commands, as an example:
$adb -d shell
# su
# cd /dbdata/databases/com.android.browser
# sqlite3 browser.db
sqlite> .tables
.tables
android_metadata bookmarks folders searches
sqlite> select * from bookmarks;
(listed all my bookmarks)
Basically, you can run any SQL command from adb on any database you open (provided you run it as su)
Another option to consider would be making a test build of your application which adds a button to copy the database over to the sdcard where you can browse it from the PC.
Alternatively, you could set the mode of the database file to shared, but you still won't be able to browse to it - you would have to tell the file browser to go directly to the database file (ie, type its full path in) since you can't browse intervening levels of folders such as /data itself. I don't know if the browser lets you do that (it's not opening at all for me today, but then I never use it since I like command line shells ;-)
精彩评论