[英]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.