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.
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?
Related
I am building the Android 9 Pie GSI from the AOSP and flashing it into the PIXEL 3XL. I have my own application and I have added it to the Android 9 Pie GSI ROM - so this application builds together with the ROM. This application has privileged app permissions (located in /system/priv-app) and its data must be protected from the userdata wiping.
I tried to use the /persist for this purpose, but it's read only. I tried the /mnt/vendor/persist/ and I got the "permission denied" error.
What folder can I use to save the apps data?
The answer here at: https://android.stackexchange.com/a/47951/56147 will help. Please take a look at it. In summary the link says that:
"All apps (root or not) have a default data directory, which is /data/data/<package_name>. By default, the apps databases, settings, and all other data go here. If an app expects huge amounts of data to be stored, or for other reasons wants to "be nice to internal storage", there's a corresponding directory on the SDCard (Android/data/<package_name>)."
which I believe is mostly correct and should help set you on the right path. As you have root access, you can write anywhere, including where the user has no access.
I'm making an app that read messages from Whatsapp, Viber, mails, etc. and groups it so you can read all that one person said to you in just one App.
To do this I'm trying to read the *.db files each App has on /data/data directory but have encountered two problems.
Since I'm new to programing for rooted phones I don't know how this works and have not found a good tutorial or any documentation. Do you have any that I could read to understand?
Once I know how to access /data/data with root, how can I read the *.db without making a copy. Many other topics say that I should copy the *.db file to a folder and read it there, but wouldn't it be a lot more simple to just read it from where it is?
Apps, regardless of whether the phone is rooted or not, can only ever read files that they themselves own, or that are public (e.g., on a SD card). This is because while the phone may be rooted, the apps themselves do not gain root access.
Instead, on your phone, you have an executable named su lets apps run root commands. However, by default, it refuses to let any app run any root commands. When you root your phone, you replace this executable by a new, modified version that lets approved apps run root commands. It is by using these root commands that you can gain indirect root access to the system.
Now, since you only have indirect root access for your app, you cannot just read any file from the file system. But if you run a root command to copy it to your own, private directory, where you do have permission to read it, your app can directly read it from there.
(Note: you can technically read files without copying them first, by using the su executable, but unless there's a real reason why you can't copy first, and you actually know what you're doing, you probably shouldn't even bother because it's rarely worth the trouble anyways, especially not for sqlite databases.)
For details about how to run root commands with su, see this link (which Gumbo posted in the comments above).
I am working on a project that needs to store some .txt to android, and get it from the computer for other use. From what I read from the documentation, I know that there are two types of storage: 1 Internal, which is somewhere deep in the phone that is private to the app. 2 External, which includes the SD card and the Internal Storage of the phone. I want to store it to External->Internal, and I am using this line of code to do that:
public String WalkDir = android.os.Environment.getExternalStorageDirectory().getAbsolutePath() + "/Walks/";
When I logged WalkDir, LogCat says "/storage/emulated/0", I stopped the app, checked with the adb shell, and there is no folder "0" but "legacy". I unplugged the phone and plugged it back in, the "Walks" folder is now in the root directory, and I don't need adb shell to access it.
So my question is, can you help explain how this system works? Why did "0" disappear? What is "legacy"? Why is the file in Internal Storage when I unplug&plug it?
Thank you very much!
Those are what in Linux are called symlinks (like shortcuts in Windows) that various system apps in Android are using..
/storage, /sdcard are sym linked folders,that means when you open one of those, it redirects to the original(/data/media/0), as for the 0 is just a multi user feature implemented in android 4.2, but only enabled on tablet androids.
Why do this Sym-Link?: simple so it dosent break apps(not only file explorer type of app, but all apps).
Still dont get, why it would break?.Simple. android api have lots of ways to write/read files from folders, u can do manually,u can get the data path, u can get the sdcard path, etc,etc. so to not break that they just does these sym links, thats why in one app the storage contentents are listed on /sdcard but on others, is /storage, etc,etc. one example of an app that broke because of these changes to android is titanium backup, u need to change the internal storage on it, so it work.
2 mount points pointing to the same storage device and partition.
If you create something in one folder, it will show up in the other. Same applies for deleting stuff.
They do not take away more storage space, as it is only available once but shown twice.
You also don't need to worry about it in any way because file browsers normally set their default directory to one of these locations.
As far as i know, Google changed the mount points in Android 4.2 to /storage/emulated/0/ due to them switching to MTP and EXT4(?) for the sdcard. The other mount points are still there for compatibility.
I searched a lot in DDMS all folders but can not find the location of my package folder in file manager. I have search it into the storage/sdcard0 but there also my package is not present.
take a look I uploaded photo. Is there any special setting from mobile ?
My phone android version 4.4.2
please help me to find.
UPDATE
I gone through this steps.
And I reach to My database folder .Now What to do.
adb shell
run-as com.mypackage
ls
cd databases
ls
Now After this what to do.
As you are looking for the database.
I used to copy the database file to any other location after updating it. ( in my code)
Then I use any sqlite viewer over phone or over PC to view it.
I Think you need a rooted device
as far as I know the files on sdcard/Android/data are not the primary files for the packages, those are only extra files (most probably not critical and large files) which are saved on the external storage which is the sdcard.
main package files are saved on the internal storage.
I think you can try this link
http://developer.android.com/guide/topics/data/install-location.html
you can change the location of app installation.
Br,
You can't see the files in DDMS, but you can get a list of the location of all the files using the command:
adb shell pm list packages -f
(you can also add an optional extra parameter to restrict the files listed to be those that match your extra parameter).
Once you have the location of the file, you can then issue a command like
adb pull /system/app/GoogleEarth.apk
to actually get the file off the device and on to your PC.
None of this requires a rooted device.
Since you're looking for the database of your application: Unfortunately there's no way to access the /data/data/your.package.name/databases through DDMS on an unrooted device, as Hussein Ali pointed out correctly. (By the way: The app-data (shared prefs, databases) will reside there no matter of the install-location)
Something like this won't work neither because of Permission denied.
adb pull /data/data/your.package.name/databases/db.sl3
Luckily ICS (Android 4.0) introducted the ability to backup your application-data. That's a possible way to copy your database from your unrooted device to your PC. Please see this post on StackOverflow in order to see what you need to do.
copy the database file to your SD card so you'll be able to use adb pull and get the database to your PC (You can't pull files from private folders such as /data/data/...).
I recommend using SQLite Expert to browse the DB on your desktop:
http://www.sqliteexpert.com/
Also, If you still want to use sqlite3 on your device, check out this answer: https://stackoverflow.com/a/7878236/624109
phone storage is treated as external storage in location "sdcard" where you havn't saved anything so nothing(package named folder) is created... your package will be in app's "private storage" that's in root "data/data/pkg_name" folder accessible only on rooted device.
I'm porting a C++ Linux application to Android using NDK and testing using the emulator. The application tries to create an /etc/myApp directory and fails because the component /etc does not have the necessary write file system permissions required to create.
Should my application be able to create such a directory? I used adb to inspect and try to make the directory from the shell and it fails too:
mkdir failed for myApp, Read-only file system
Does the file system being read only in adb mean it is also read-only for my application?
Can my application expect to create this directory and if not, is there another location that is more appropriate?
No, you should not be able to do that. Android apps are not permitted to write to system directories.
You should probably create this directory within your app's private storage area. Generally it is best to discover the path of that from Java (don't hardcode it) and then pass it through to the native side.
Depending on your needs for the file, the ExternalStorage might also be an option, especially during development where you might need to easily modify it manually - though keep in mind that others things will be able to change it there, too. Again, you should determine the path on your particular device in Java and then pass that through to the native code.