Reading database file from android device

。_饼干妹妹 提交于 2019-12-07 14:13:35

问题


I've been trying to pull a copy of my sqlite database from my android app for dev. My first attempt was to call:

./adb shell
cd data/data
cd com.example.app
cd databases

But then I get stuck here as I do not have permission to do a pull or even view the files in that dir!

So I thought I'd try out the DDMS File Explorer which gives me this:

But when I try and pull files from here (I would expect them to be in the data folder) it just pulls the directory and nothing else. How can I do this to pull a copy of the database my app is creating/using?

I have tried this when the phone is on the SD card and on phone memory. I guess I could copy to SD card and then plug the SD card to pc rather than the phone and do it that way? Not sure if it would work and would be rather annoying to dev like that!

Thanks


回答1:


IF you just need the DB for general checking/viewing you can run your app on the emulator and get the DB from there. If you need the specific instance on your device you need to root your device as others are suggesting.




回答2:


If your device does not give you access to this directory (and your device is not rooted -- if you become root, you'll have access), you will need assistance from your application.

The application can, for example, copy databases/your_database_name.db to a readable location, perhaps on the SD card. Then you can pull from there.



来源:https://stackoverflow.com/questions/6154092/reading-database-file-from-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!