从Android设备读取数据库文件
我一直在尝试从我的 Android 应用程序中提取 SQLite 数据库的副本以供开发。我的第一次尝试是调用:
./adb shell
cd data/data
cd com.example.app
cd databases
但后来我被困在这里,因为我没有权限进行pull
,甚至没有权限查看该目录中的文件!
所以我想尝试一下 DDMS 文件资源管理器,它给了我这个:
但是当我尝试从这里提取文件时(我希望它们位于数据文件夹中),它只是提取目录,仅此而已。我该如何执行此操作来提取我的应用程序正在创建/使用的数据库的副本?
当手机位于 SD 卡和手机内存上时,我尝试过此操作。我想我可以复制到SD卡,然后将SD卡插入电脑而不是手机,然后这样做?不确定它是否会起作用,并且这样对开发人员来说会很烦人!
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的设备不允许您访问此目录(并且您的设备未获得 root 权限 - 如果您成为 root 权限,则可以访问),您将需要应用程序的帮助。
例如,应用程序可以将
databases/your_database_name.db
复制到可读位置,可能在SD卡上。然后你可以从那里拉。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.如果您只需要数据库进行一般检查/查看,您可以在模拟器上运行您的应用程序并从那里获取数据库。如果您需要设备上的特定实例,则需要按照其他人的建议对设备进行 root 操作。
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.