gpt4 book ai didi

android - 如何使用 Android Device Monitor 的文件资源管理器查找我的应用程序/数据/数据

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:42:31 29 4
gpt4 key购买 nike

我有一个应用程序可以将文本文件写入内部存储。我想仔细看看我的电脑。

我运行了 Toast.makeText 来显示路径,它说:/数据/数据/我的包

但是当我转到 Android Studio 的 Android Device Monitor 应用程序时,我在文件资源管理器中看不到/data/data。那么我的文件在哪里?

我知道它们存在,因为我可以在 adb shell 上找到它们。我需要将/data/data 转换为文件资源管理器上可见的路径,以便我可以轻松下载它们。谢谢!

最佳答案

您只能检查是否有 root 手机,因为这些文件夹对应用程序是私有(private)的,并且通常访问仅限于这些文件夹。如果您没有 root 手机,我会建议您复制一份内部文件夹并将它们写入您的 SDCard 以检查内容。另一种方法是对手机进行 root 或使用模拟器。

这是您可以用来在外部 SDCard 上写入副本的代码:

public static void copyDirectoryOneLocationToAnotherLocation(File sourceLocation, File targetLocation)
throws IOException {

if (sourceLocation.isDirectory()) {
if (!targetLocation.exists()) {
targetLocation.mkdir();
}

String[] children = sourceLocation.list();
for (int i = 0; i < sourceLocation.listFiles().length; i++) {

copyDirectoryOneLocationToAnotherLocation(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
}
} else {

InputStream in = new FileInputStream(sourceLocation);

OutputStream out = new FileOutputStream(targetLocation);

// Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}

}

关于android - 如何使用 Android Device Monitor 的文件资源管理器查找我的应用程序/数据/数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25616985/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com