Android设备监控“数据"文件夹为空 [英] Android Device Monitor "data" folder is empty

查看:45
本文介绍了Android设备监控“数据"文件夹为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经测试了在我的应用程序数据库中创建、插入和检索数据的过程,并且通过使用 Log 语句知道它可以工作.

I have tested creating, inserting and retrieving data into my apps db, and know it works through usage of Log statements.

但是,我希望加快测试速度并使用 Android Device Monitor.但是,虽然db存在并且数据已经存储,但是在下面访问时,data文件夹是空的:

However, I wish to expedite testing and use the Android Device Monitor. However, though the db exists and data is stored, when accessing below, the data folder is empty:

为什么会这样?如何配置它以显示 db 文件和内容?

Why would this be the case? How can this be configured to show the db file and contents?

推荐答案

使用模拟器解决问题

文件夹 /data 可能是空的,因为您缺少适当的权限.为了解决它,我不得不执行以下命令.

Solving the issue using an emulator

The folder /data can be empty because you are missing the proper permissions. To solve it, I had to execute the following commands.

adb shell
su

这些命令会在模拟器中启动一个 shell 并授予您 root 权限.命令adb位于Android SDK的platform-tools文件夹中,MacOS上一般安装在~/Library/Android/sdk/.

Those commands starts a shell in the emulator and grant you root rights. The command adb is located in the folder platform-tools of the Android SDK, typically installed in ~/Library/Android/sdk/ on MacOS.

chmod -R 777 /data

修改文件夹(以及递归子文件夹)的权限/data,使其出现在工具Android Device Monitor中.

Modify the permissions of the folder (and subfolders recursively) /data in order to make them appear in the tool Android Device Monitor.

adb root

最后,此命令以 root 身份重新启动 adb.请注意,它仅适用于开发版本(通常是模拟器版本).

Finally, this command restarts adb as root. Be careful, it only works on development builds (typically emulators builds).

之后,您可以看到文件夹/data 的内容并传输位于其中的数据.您也可以在控制台中使用adb pull ,如:

Afterwards, you can see the content of the folder /data and transfer the data located in. You can do it in console as well, using adb pull <remote> <locale>, such as:

adb pull /data/data/<app name>/databases/<database> .

这篇关于Android设备监控“数据"文件夹为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆