herbertD
herbertD

Reputation: 10955

Why can't 'data' folder be displayed just like in DDMS file explorer?

I list out files in '/' by:

File directory = new File("/");
fill_listview(directory.listFiles());

And I get those in list:

sqlite_stmt_journals
config
cache
sdcard
d
etc
system
sys
sbin
proc
init.rc
init.goldfish.rc
init
default.prop
data
root
dev

I have two questions:

1.Why cann't I access '/data' folder just like Eclipse DDMS file explorer?

2.Why it is different from the DDMS which show only:

data
sdcard
system

Thanks!

Upvotes: 5

Views: 7449

Answers (3)

user3137329
user3137329

Reputation:

I did this on a non-rooted device and it worked

   run-as com.your.package ls -l /data/data/com.your.package
   run-as com.your.package rm /data/data/com.your.package/databases/mydatabase.db

Reference: http://denniskubes.com/2012/09/25/read-android-data-folder-without-rooting/

Upvotes: 0

peceps
peceps

Reputation: 17557

On rooted device you can do this to access the /data folder:

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

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

Upvotes: 12

bhups
bhups

Reputation: 14885

It is mostly because of security issues. If /data folder is visible to everyone, then some malicious app can read/temper/delete the data of some other app which can get really worse if some app is storing some sensitive data like password/credit card number etc. So the whole filesystem is only visible via debug console (or ddms).
You can not access data of any app on the device unless it is rooted because by doing so, integrity of system might be compromised and it may lead of weird behavior. Which means you can not access cached data/databases of app.

Upvotes: 7

Related Questions