是否可以从 adb shell 中查看应用程序数据,就像我看到它安装 SD 卡一样?
我正在测试 Android 应用程序。
关注内容
/sdcard/Android/data/com.myapplication
我想在应用程序运行时 。
但如果 SD 卡作为磁盘驱动器安装在 PC 上(访问图片和视频),我的应用程序将无法正常工作。
所以我想我可以使用 adb shell。但它不允许我访问同一个文件夹:
ls /sdcard/Android/data/com.myapplication
/sdcard/Android/data/com.myapplication: Permission denied
查看 Stack Overflow,我发现通过 adb shell 查看应用程序数据的方式:
run-as com.myapplication
这样做我发现自己在该文件夹中
/data/data/com.myapplication
我感到困惑的是我看到的数据这与我通过PC浏览SD卡内容看到的数据不同。
$ ls
ls
files
databases
shared_prefs
lib
我在文件下看到一些也在 sdcard Android/data/com.myapplication 文件夹下的东西,但不是我正在寻找的东西。此外,所有其他文件夹都不同。
之间是否存在关联
/data/data/com.myapplication
通过 adb 访问的此文件夹与
/sdcard/Android/data/com.myapplication
通过 PC 访问的文件夹 ?
有没有办法在 adb shell 中查看后者中存在的文件?
I am testing an Android application.
I would like to keep an eye on the content of
/sdcard/Android/data/com.myapplication
while the app is running.
But my app does not work correctly if the sd card is mounted as disk drive on PC (accesses pictures and videos).
So I thought I could use adb shell. But it doesn't let me access that same folder:
ls /sdcard/Android/data/com.myapplication
/sdcard/Android/data/com.myapplication: Permission denied
Looking on Stack Overflow, I found this way to see application data via adb shell:
run-as com.myapplication
and doing so I find myself in the folder
/data/data/com.myapplication
What I'm confused about is that the data I see here are different from the data I see browsing the sdcard content via PC.
$ ls
ls
files
databases
shared_prefs
lib
I see under files something that was also under the sdcard Android/data/com.myapplication folder, but not what I was looking for. Besides, all other folders are different.
Is there a correlation between this
/data/data/com.myapplication
folder accessible via adb and the
/sdcard/Android/data/com.myapplication
folder accessible via PC?
Is there a way to see in adb shell the files present in the latter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为一般规则,位于
内部存储
上并由您的应用存储的文件(默认情况下不是WORLD_READABLE
)仅可供您的应用读取。当您尝试使用adb pull
来拉
这些文件时,您将在未获得 root 权限的设备上获得拒绝权限。有一种方法可以解决这个问题,我稍后会解释。另一方面,外部存储
中的文件可供用户和所有其他应用程序读取。所以这取决于你想要什么。现在,为了读取内部存储中的文件 (
/data /data/com.app.name
)您无法直接读取这些文件,但您可以将它们移动到 外部存储,然后像这样从那里读取它们。然后您可以从外部存储中提取文件,而不会出现权限问题。
如果您不确定哪个文件或想要浏览所有文件,请使用 shell 浏览所有应用程序文件。
As a general rule, files that are on the
Internal storage
and stored by your app (by default notWORLD_READABLE
) will only be available for your application to read. When you try topull
these files usingadb pull
you will get permission denied on a NOT rooted device. There is a way to go around this, I will explain later. Files inExternal storage
on the other hand, are available to the User and to all other apps to read. so it depends on what you are after.Now in order to read files in your internal storage (
/data/data/com.app.name
) you cannot read these files directly, but what you can do is move them to the external storage and then read them from there like this.Then you can pull the file from the external storage with no permission issues.
If you are unsure about which file or you want to browse all the files, then user the shell to browse all your app files.
我已经能够通过以下 Adb 命令获取应用程序正在使用的 Sqlite DB:
其中 xxx.xxx.xxx.xxx 是 Android 应用程序的 bundleId,databasefile.db 是 Sqlite DB 的名称
所以我想你可以获取应用程序的任何现有文件,知道它在哪里,然后使用
adb exec-out run-as xxx.xxx.xxx.xxx
命令I have been able to get the Sqlite DB the App is using with this Adb command:
Where xxx.xxx.xxx.xxx is the bundleId of your Android App, and databasefile.db is the name of the Sqlite DB
So I imagine you can get any existing file of the App, knowing where is it, and using the
adb exec-out run-as xxx.xxx.xxx.xxx
command您可以通过之前在博客中发布的实用程序来访问它。
它是一个java实用程序,通过它您只需提供应用程序的包名称即可获取应用程序数据文件夹中的所有文件夹。
只是应用程序需要可调试。
提取 Android 文件
确实有效
You can access it via utility which was posted earlier in a blog.
Its a java utility through which you can get the all folders in your application's data folder by just giving the package name of your application.
Just app needs to be debuggable.
Extract Android Files
Really works