0

I fully read the documentation of Cordova plugin filesystem. Furthermoe I've been googling without though conclusive explanations.

Particularly, how do the paths stored in the variables in cordova.file.* map the real folders in Android filesystem that you can see on any File Explorer? For example, I cannot save a file into the Downloads folder. I tried file:///android_asset/Download without success.

What exactly is the protocol file:/// and the path file:///android_asset/? What is the "application's sandbox"?

For example, I save a file into cordova.file.cacheDirectory because I need to deal with a temporary file, but I tried to find such file within a file explorer, and I can't find such file. Is it hidden somehow? I can't find it neither in /data/data/<app-id>/cache nor in "file:///data/user/0/com.form.parking.violation/cache/" (real value of that string).

I know, it's too many questions, but I will plan to make this a canonical question, since clear and pedagogical information is very scarce.

João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109

1 Answers1

1

Using a 'File Manager' app on device won't give you access to items listed as 'Private' in the documentation you've listed. 'Private' means no other app should be able to see the contents which is sort-of described by "application sandbox". Normally a sandbox is for describing an environment which something can't get out of. If you aren't familiar with multi-user environments it can also mean that others without the right level of permission can't see in.

And unless the device you are testing on is rooted, you won't be able to see those 'private' files like the SQLite database and other files you are interested in unless you use adb from the Android SDK with the adb shell command run-as as described here:

Android ADB access to application databases without root

Note that to grab the files you need to have your Cordova app debuggable by Android Studio (debug mode).

For what is file:///android_asset/ I'll refer to this SO question:

What does file:///android_asset/www/index.html mean?

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
  • I have access to the android file system with ubuntu connected with USB cable, thus I think I have no restrictions. I still don't get the meaning of `file:///data/user/0/com.form.parking.violation/cache/`. To where this points to? What does it mean `file:///data/user/0/`? Thank you – João Pimentel Ferreira May 20 '18 at 08:18
  • 1
    You don't mention what device(s) you are testing with. See if you can replicate with a Android emulator build. And be clear if you have attempted with `adb run-as` and unsuccessful. – Morrison Chang May 20 '18 at 20:48