77

While testing my apps, I use emulators and my own phone to see if everything is working ok. My apps are also writing data to shared preferences and a text file.

I can pull the data from my emulators through the DDMS in eclipse so I can read the data files on my computer, but when I try to open those folders through the DDMS on my phone, nothing happens. I click the data folder and nothing happens.

My phone is rooted. Is there any way I could pull the files from my phone? I know that Android keeps these folders private, but there must be a way. The emulator is just way too slow.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
dell116
  • 5,835
  • 9
  • 52
  • 70
  • 4
    how to do this on a *non-rooted* phone? – likejudo Mar 18 '14 at 01:30
  • I don't think it's possible considering you'll need to change the file-system permissions on those files/folders. This can't be done without a rooted device. – dell116 Mar 18 '14 at 15:05

10 Answers10

160

On rooted device you can do this:

  1. Open cmd
  2. Type adb shell
  3. su
  4. Press 'Allow' on device
  5. chmod 777 /data /data/data /data/data/com.application.package/data/data/com.application.package/*
  6. Go to the DDMS view in Eclipse

After this you should be able to browse the files on the device.

To get the databases:

  1. chmod 777 /data/data/com.application.package/databases /data/data/com.application.package/databases/*

If it returns permission denied on su

Go to Settings > Developer Options > Root access > Apps and ADB

peceps
  • 17,370
  • 11
  • 72
  • 79
  • Finally....this works! Almost one year later and peceps comes through. So I'm guessing this problem has to do with the file system permissions? – dell116 Jan 17 '12 at 16:39
  • yes, it is a protection to prevent some application messing with other application files. – peceps Jan 18 '12 at 09:32
  • Hi peceps, im able to see the db file in databases folder, but unable to pull file from there...Im getting "Failed to pull selection" error in console. I just like to see the db file. I tried restarting PC, Eclipse and device... bt no use. pls let me know how i can pull file nw.. – praveenb Apr 26 '12 at 08:29
  • I rooted my phone now I see nothing in DDMS. I can see through `adb shell` though. – darren May 11 '12 at 17:21
  • 3
    @Praveenb, I had same problem, but then I repeated above chmod command with additional folders: /data/data/com.application.package/databases /data/data/com.application.packages/databases/* – Tom May 26 '12 at 03:42
  • 6
    @peceps : My phone is not rooted. The command in Step 3 work does not work for me. It says permission denied. There is no 'Allow' in the device. – Ashwin Sep 05 '12 at 03:01
  • @peceps : You have given the process for accessing data/data on a rooted phone. But is there a way to do that in non-rooted phone or is perfectly secure? – Ashwin Sep 05 '12 at 10:43
  • @Ashwin I don't think there is a way of doing this on non-rooted phone. – peceps Sep 06 '12 at 10:44
  • Hi @peceps, I'm able to access the /data folder using the Terminal Emulator app but not `adb shell su` due to "permission denied" error - http://stackoverflow.com/questions/18226210/cannot-open-data-folder-in-a-rooted-android-device – ericn Aug 14 '13 at 08:03
  • @fuzzybee try only 'su'. See if you get a popup on the device asking you to allow the command. – peceps Aug 19 '13 at 11:18
  • I get this on my non-rooted Galaxy S3: `/system/bin/sh: su: not found`. – PurkkaKoodari Sep 07 '13 at 14:42
  • In developer options you may set Root Access to ADB – Gunnar Bernstein Sep 21 '13 at 16:18
  • 3
    use `chmod -R 777 /data/data/` to apply this command recursively – Konstantin Milyutin Feb 10 '14 at 10:04
  • @damular on my rooted Xperia Arc S I get: BAD MODE with -R – Yar Oct 09 '14 at 16:14
  • 2
    I get "su: not found" when I try to run su after "adb shell". (I am using a non-rooted phone) – Sarang Dec 15 '14 at 09:25
  • I can't understand why this is the accepted answer and has so many upvotes!? Yes, I suppose technically it will allow me to drill down in to data/data/... and see my databases, but the permissions don't allow me to pull my database off the phone which is the crux of the question – Simon Hutton Nov 25 '16 at 00:01
  • @SimonH on rooted devices you can pull the database also, just do chmod 777 /data/data/com.application.package/databases/ chmod 777 /data/data/com.application.package/databases/* – peceps Dec 07 '16 at 08:27
  • @peceps I appreciate you taking the time to answer my comment. I've now gone a different route and installed Root Explorer (ok it cost me a couple of quid!) which allows me to copy the database out if the root folder and place it somewhere where I can get to it easily. – Simon Hutton Dec 07 '16 at 16:43
6

No one seems to understand that a retail Nexus One even after being rooted still will not let you browse the file system using DDMS File Explorer. We are talking about real phones here and not the emulator. If you happen to have a Nexus One Developer Phone you can browse the file system using DDMS Filer Explorer, but a retail Nexus One that has been rooted you can't. Got it?

So I hope that answers the question of not being able to use the DDMS File Explorer to browse the file system of a rooted retail Nexus One. After rooting a retail Nexus One there is still something that remains to be done to use DDMS to use the File Explorer to browse the phones File System. I don't know what it is. Maybe someone else knowns.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Vince
  • 405
  • 5
  • 19
4

If gives "permission denied" on adb shell -> su...

Some ROMs are running adbd daemon in secure mode (adbd has no root access and su command does not even show permission ask dialog on the device). In this case you will get "permission denied" when you try cmd -> adb shell -> su. The solution I've found is one app from the famous modder Chainfire called Adbd Insecure.

WindRider
  • 11,958
  • 6
  • 50
  • 57
  • 1
    In CyanoGenMod, go to setup-->Developer options-->root access and change to 'adb and apps' (default is 'apps') – JRun Oct 13 '13 at 19:45
3

You must edit permission of data folder.

I use "Root Explorer" (see market) app on root mode.

On top select "Monunted as r/w"

then press over data folder (long click) and find Permission option

Have a somenthing like that

        read    write  execute

User

Group

Others

Make sure that "Others" have a check for read

Then go Eclpse and try again.

Sorry about my english,I hope can help you.

cristianego
  • 81
  • 1
  • 7
2

To set permission on the data folder and all it's subfolders and files:
Open command prompt from the ADB folder:

>> adb shell
>> su
>> find /data -type d -exec chmod 777 {} \;
2

Much simpler than messing around with permissions in the android FS (which always feels like
a hack for me - because i believe there must be a kind of integrated way) is just to:

Allow ADB root access and Restart the deamon with root permissions.

  1. First be sure that ADB can have root access on your device (or emulator):
    (Settings -> Developer Options -> Root-Access for ADB or Apps & ADB.
  2. Restart the ADB-Service with root-permissions:
    Open a command prompt and type: adb.exe root
  3. Restart ADM (Android Device Manager):
    Enjoy browsing all files
  4. To negate this process:
    Type adb.exe unroot in your command prompt.
Cadburry
  • 1,844
  • 10
  • 21
1

Event though it's a bit too late to try to answer this I'll leave what worked for me.

Peceps's solution didn't work because the SuperUser app didn't allow "shell" to have root access. So my solution is to directly use another app like RootExplorer and browse the folders from it.

Gonan
  • 588
  • 7
  • 18
  • 1
    I have to say that of all the answers listing adb commands, changing permissions and fiddling about with DDMS that has meant me wasting a whole evening (that I could have spent watching football)... this has been the only, best and simplest solution that has actually allowed me to get to read my database. Much respect and thanks. – Simon Hutton Nov 24 '16 at 23:57
1

If it retures "permission denied" on adb shell -> su...

Go to "Developer Options" -> Root access -> "Apps and ADB"

Gunnar Bernstein
  • 6,074
  • 2
  • 45
  • 67
0

When I say file system I meant the whole file system. But you can only browse part of the file system on a retail phone, perhaps even most of file system but not ./data. Sorry for any confusion this may have caused.

This is alarming to me because I have a rooted my retail Nexus One and a developer/unlocked Nexus One. Since I rooted my retail Nexus One I can't figure out why I can't browse the whole file system like I can on my developer Nexus One.

Vince
  • 405
  • 5
  • 19
-3

If you NEED to do it on your phone, I use a terminal emulator and standard linux commands.

Example:

  1. su
  2. cd data
  3. cd com.yourappp
  4. ls or cd into cache/shared_prefs

http://www.appbrain.com/app/android-terminal-emulator/jackpal.androidterm

sgarman
  • 6,152
  • 5
  • 40
  • 44
  • No you don't need to do that. – Octavian Helm Feb 01 '11 at 21:57
  • 3
    @ Octavian - You're telling me that you can pull files from a real phone, not an emulator, through file explorer in the DDMS? Whenever I click on the "data" folder in file explorer, it does not populate the tree. Your answer below only works for me if I'm using an emulator, not a real phone. – dell116 Feb 01 '11 at 22:57
  • 1
    If you need to access the data folder then you have to use rooted devices. – Siddharth_Vyas Sep 05 '13 at 03:57