12

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!

Gerard
  • 638
  • 4
  • 8
  • 19
  • Isn't your package there? like data/data/yourpackage? And this is not possible on user build. – Pankaj Kumar Sep 02 '14 at 06:28
  • Not exactly a duplicate. I tried that SO entry you linked to last weekend already. The problem is, when I use their cp command, I can't get it to copy from adb to my laptop. I also tried to use the backup route, but my phone is encrypted and I must enter my crypto password or else it doesn't proceed. So, I'm trying to use Android Studio's Android Device Monitor application, to do a pull. But, the path /data/data is not showing up. That's why I'm asking this SO question, specifically for translating /data/data's path into a path that's reflected on Android Studio's Android Device Monitor. – Gerard Sep 03 '14 at 04:06
  • Opened the question now :) – Pankaj Kumar Sep 03 '14 at 05:40

5 Answers5

5

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();
        }

    }
Skynet
  • 7,820
  • 5
  • 44
  • 80
  • 1
    I was hoping I didn't need to do this, but given the circumstance copying to SD card is simpler than rooting just to get to a few files. Thanks. – Gerard Sep 03 '14 at 05:13
4

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

After that you can open the data folder.

Himanshu Agarwal
  • 4,623
  • 5
  • 35
  • 49
Alex
  • 41
  • 1
1

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).

Community
  • 1
  • 1
suitianshi
  • 3,300
  • 1
  • 17
  • 34
  • Isn't there a way to make my app's content appear in a visible path to Android Device Monitor's file explorer? I've tried both option 1 and 2 in your link last weekend already. The 1st gets me a syntax error on cp. The 2nd I end up with an encrypted backup, but how to decrypt? My phone is encrypted. When I choose not to encrypt as instructed, it quits. If I encrypt, don't know how to decrypt. So I'm stuck. – Gerard Sep 03 '14 at 04:14
  • Sorry, I have no idea, you can try root your device. For the cp syntax error, it's actually the same command as cp in Linux. It uses two arguments and various options. See http://linux.die.net/man/1/cp. – suitianshi Sep 03 '14 at 04:49
0

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

Peppe L-G
  • 7,351
  • 2
  • 25
  • 50
0

I think you're using API 24 or above, You must to create a new virtual device wihch does not API 24+

ahmeturhan
  • 57
  • 2
  • 5