是否有可能从亚行的shell看到应用程序数据我看到它安装SD卡一样吗?我看、有可能、到它、应用程序

2023-09-06 02:47:25 作者:有点上瘾

我正在测试Android应用程序。 我想留意的

I am testing an Android application. I would like to keep an eye on the content of

/sdcard/Android/data/com.myapplication   

而应用程序正在运行。 但是,我的应用程序如果SD卡安装作为PC磁盘驱动器(访问图片和视频)无法正常工作。 所以,我想我可以使用adb外壳。不过,这并不让我访问同一个文件夹:

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

我感到困惑的是,我在这里看到的数据是从我看到浏览通过PC的SD卡内容的数据不同。

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

我下的文件的东西,也是在SD卡的Andr​​oid /数据/ com.myapplication文件夹中看到的,但不是我所期待的。此外,所有其他文件夹是不同的。 有没有这之间的相关性

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

通过ADB访问的文件夹和

folder accessible via adb and the

/sdcard/Android/data/com.myapplication 

通过PC访问的文件夹? 有没有办法看到ADB命令行中的文件present在后?

folder accessible via PC? Is there a way to see in adb shell the files present in the latter?

推荐答案

作为一般规则,文件都在内部存储和您的应用程序存储(默认情况下,没有 WORLD_READABLE )将只适用于您的应用程序读取。当您尝试这些文件使用亚行拉您将得到否认了不是源于设备的权限。有一种方法去解决这个问题,我稍后会解释。在另一方面外部存储文件,可向用户和所有其他应用程序读取。所以这取决于你所追求的。

As a general rule, files that are on the Internal storage and stored by your app (by default not WORLD_READABLE) will only be available for your application to read. When you try to pull these files using adb pull you will get permission denied on a NOT rooted device. There is a way to go around this, I will explain later. Files in External 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.

现在为了读取在内部存储文件( /data/data/com.app.name ),你不能直接读取这些文件,但你可以做的是将其移动到的