简体   繁体   中英

How to Find my App's /data/data using Android Device Monitor's File Explorer

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

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?

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!

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.

Here is the code you can use to write a copy on your External 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();
        }

    }

You can use the adb console . Just write adb root and then adb connect <IP>

After that you can open the data folder.

See this . Because /data/data is internal storage for the application itself, only apps with the same user id can acess it (or unless you have a rooted device).

The /data/data folder is shown in my Android Device Monitor's File Explorer (Android Studio 1.4). At least for virtual devices.

我认为您使用的是API 24或更高版本,您必须创建一个新的虚拟设备,而不是API 24+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM