如何使用 Android Device Monitor 的文件资源管理器查找我的应用程序的 /data/data
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25616985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Find my App's /data/data using Android Device Monitor's File Explorer
提问by Gerard
I have an app that writes to text files onto Internal storage. I'd like to take a close look on my computer.
我有一个将文本文件写入内部存储的应用程序。我想仔细看看我的电脑。
I ran a Toast.makeText to display the path, it says: /data/data/mypackage
我跑了一个 Toast.makeText 来显示路径,它说:/data/data/mypackage
But when I go to Android Studio's Android Device Monitor application, I don't see /data/data in the File Explorer. So where are my files?
但是当我转到 Android Studio 的 Android Device Monitor 应用程序时,我在文件资源管理器中看不到 /data/data。那么我的文件在哪里?
I know they exist because I can find the on adb shell. I need to translate /data/data to a path visible on File Explorer, so that I can download them easily. Thanks!
我知道它们存在是因为我可以找到 adb shell。我需要将 /data/data 转换为文件资源管理器上可见的路径,以便我可以轻松下载它们。谢谢!
采纳答案by Skynet
You can only check that if you have a rooted phone, because these folders are private to applications and usual access is restricted to such folders. I would advise if you dont have a rooted phone then make a copy of your internal folders and write them to your SDCard to check the contents. The other way is to root your phone or use an Emulator.
您只能检查是否有 root 手机,因为这些文件夹是应用程序私有的,并且通常访问仅限于这些文件夹。如果您没有root手机,我会建议您复制您的内部文件夹并将它们写入您的SDCard以检查内容。另一种方法是root你的手机或使用模拟器。
Here is the code you can use to write a copy on your External SDCard:
以下是可用于在外部 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();
}
}
回答by Alex
You can use the adb console
.
Just write adb root
and thenadb connect <IP>
您可以使用adb console
. 只写adb root
然后adb connect <IP>
After that you can open the data folder.
之后,您可以打开数据文件夹。
回答by suitianshi
回答by Peppe L-G
The /data/data
folder is shown in my Android Device Monitor's File Explorer (Android Studio 1.4). At least for virtual devices.
该/data/data
文件夹显示在我的 Android 设备监视器的文件资源管理器 (Android Studio 1.4) 中。至少对于虚拟设备。
回答by ahmeturhan
I think you're using API 24 or above, You must to create a new virtual device wihch does not API 24+
我认为您正在使用 API 24 或更高版本,您必须创建一个新的虚拟设备,其中没有 API 24+