![](/img/trans.png)
[英]Android Studio - Android Device Monitor's File explorer not working
[英]How to Find my App's /data/data using Android Device Monitor's File Explorer
我有一个应用程序将文本文件写入内部存储。 我想仔细看看我的电脑。
我运行了一个Toast.makeText来显示路径,它说:/ data / data / mypackage
但是当我转到Android Studio的Android Device Monitor应用程序时,我在文件资源管理器中看不到/ data / data。 那我的文件在哪里?
我知道它们存在是因为我可以在adb shell上找到它。 我需要将/ data / data转换为文件资源管理器中可见的路径,以便我可以轻松下载它们。 谢谢!
您只能检查是否有root电话,因为这些文件夹是应用程序专用的,并且通常只能访问此类文件夹。 我建议你是否没有root手机,然后复制你的内部文件夹并将它们写入SDCard以检查内容。 另一种方法是根电话或使用模拟器。
以下是可用于在外部SD卡上写入副本的代码:
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();
}
}
您可以使用adb console
。 只需编写adb root
,然后adb connect <IP>
之后,您可以打开数据文件夹。
看到这个 。 因为/ data / data是应用程序本身的内部存储,所以只有具有相同用户ID的应用才能访问它(或者除非你有一个root设备)。
/data/data
文件夹显示在我的Android设备监视器的文件资源管理器(Android Studio 1.4)中。 至少对于虚拟设备。
我认为您使用的是API 24或更高版本,您必须创建一个新的虚拟设备,而不是API 24+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.