4

I wrote an app that reads and writes a couple of data files. When I call the method getFilesDir() it returns /data/data/nel.prog.MyApp99/files (assuming my app is called MyApp99).

So how do I see that on my PC?

When I attach my phone as a debugging target to my (XP) PC I get 2 external drives created - one for the phone itself and one for the SD card, and I can't find that path in either one! In XP I set my "Folder options" to show hidden files and folders and to not hide protected operating system files. I can see a lot of stuff (i.e., lots of files and folders on both the phone and SD card). But I don't see the above path nor the data files themselves.

Where are they and how do I access them? Thanks in advance!

Peter Nelson
  • 5,917
  • 17
  • 43
  • 62

2 Answers2

3

You can use adb (Android Debug Bridge) in your adk/tools dir to copy files or start a remote shell (and then list files/contents).

adb pull <remote> <local>   // copy files

adb shell    // start shell

Update:

Above commands only work from a computer connected to Android device.

For sharing files between apps on device you should check out: http://developer.android.com/guide/topics/security/security.html#userid

Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • Instead of that, is there a way I can set a path to write and read my files to someplace that's NOT inaccessible? If so, is there a "standard" place for apps to write their data to that's public (in the phone storage, not the SD card because not everyone has one) -tnx – Peter Nelson Feb 19 '11 at 20:49
  • @Peter Knego: The `adb` trick will only work on the emulator, or possibly rooted phones. – CommonsWare Feb 19 '11 at 20:59
  • Each app is installed under separate user ID, so they don't have access to each other files. Also, each app has only privileges to its own directory where it is installed. – Peter Knego Feb 19 '11 at 20:59
  • Nelson: "If so, is there a "standard" place for apps to write their data to that's public (in the phone storage, not the SD card because not everyone has one)" -- no. If you need access to your files, test on the emulator, or implement a backup/restore feature that uses external storage. – CommonsWare Feb 19 '11 at 21:00
  • Part of my test plan is to make sure my app handles it correctly/gracefully when data files are missing, renamed, or altered/corrupt. Testing on the emulator is OK to a point, but I want to make sure everything works properly on an actual device, too. – Peter Nelson Feb 19 '11 at 21:45
  • Running Android 4.3 on an physical device, my app stored it's files in '/mnt/shell/emulated/0/' (replace with actual name). I was then able to view it using either 'adb shell' or Android Debug Monitor. Hope this helps others saving the time for the search. – Manfred Apr 19 '14 at 23:33
2

Your phone must be rooted to be able to access the /data directory. Once you did it you can use a tool like DroidExplorer to browse this folder.

Dalmas
  • 26,409
  • 9
  • 67
  • 80