I have created this file on my device:
file:///data/user/0/io.ionic.starter/files/mypdf.pdf
But I can’t figure out how to find that file manually using my android device. Any ideas?
Note: I am using an emulator, Nexus 5X.
What do you mean by "manually"?
You can not access this file from another application on your Android device, such as a file manager or a PDF viewer.
This is because you created it inside your applications files directory, which is guarded by file system permissions and is only accessible to your application.
There are two exceptions to this rule:
If your device is rooted, you can use Root explorer to find the file.
If you created the file with "world readable" permission, another application can read it if it has the exact path (including full file name).
Note this may not work on newer versions of Android.
If you wish to access the file from you PC to examine it, you can use adb pull command. Since you are using an emulator, ADB should be running as root.
If it is not, use adb root command to switch ADB to run as root, then you will have no problem accessing any directory on the phone.
Keep in mind, this will not work on a real phone with stock ROM, as ADB can not run with root privileges on production systems.
Related
I am developing an application using ionic framework.
The app creates files (*.json) and stores them in /data/user/0/ when i verify whether they exist or not, the result was true which means the files exist in the mentioned directory and I can access and modify their content without problem, but when I check the directory with a file manager or from the computer, no result, the directory is empty.
Could someone tell me what should I do?
use adb to copy the file. Even if it's in root dir, u should have access to it via adb.
Do adb pull data/user/0/filename.json path_on_ur_comp.json.
this will copy the file to the directory you define in the 2nd parameter.
// EDIT:
adb is part of the Android SDK, stands for Android Debug Bridge.
You can use this for MANY MANY different reason but of course, the "main" reason is to debug Android devices. You can use it to transfer files in your case.
In Windows, it's located here:
C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools\adb
In Mac, it's lcoated here:
/Users/USERNAME/Library/Android/sdk/platform-tools/adb
Depending on which OS you use, open that either with Terminal (Mac) or Command Prompt (Windows).
Once you do that, run the following command:
For Mac:
adb pull data/user/0/filename.json /Users/USERNAME/Desktop/somefile.json
For Windows:
adb pull data/user/0/filename.json c:\Users\USERNAME\Desktop\somefile.json
This will copy the file and put it on your desktop
I'm currently doing lab work on an upcoming device and I've hit a wall on this particular one.
I can't say the model number, but it's running Android 5.1 and the build is LMY47D
It's a user debug build - so I have the SU binary and busybox installed, and I am perfectly capable of running any and all su commands.
I have the SU binary located in "system/bin/" and it's linked to "/system/xbin/." It has root access and the correct privileges (I think). Also you can see that busybox is installed.
Where I am having the problem is installing superuser and a few other apps.
I installed the apps to the "system/app/" folder with the privileges 755 along with appdel.apk and appdel2.apk (The ones that I need to give root access too)
Here is a snapshot of the "/System/app" folder.
As you can see, everything is there with root privileges, but when I try to access the application, nothing is working.
How do I give these applications Root Access?
As a side note, I can't flash or reload this ROM. Kingo root and IRoot just about bricked the phone. The superuser that I am trying to install is 2.46, which is the same superuser that the guys at Nexus Root are using on their LMY47D devices.
This is one of the guides that I have been following (among others): http://pocketnow.com/2012/10/10/root-without-unlocking
Thank you guys
I made a filemanager that I want go be able to navegate/modify some system folders (say, /data/). I copied my apk to /system/app, gave 644 permission to the apk file, and rebooted. Yet, my app is still run without root privileges (deny simple access to /data). I'm using Cyanogenmod 11.
Any clue?
Thanks!
L.
To clarify, the app being in the /system/app folder does not run it as root. Android is linux based, so having root access means that your app is able to run shell commands as the root user.
Generally speaking an app being in the /system/app folder makes all declared permissions available to it, (for example, declaring WRITE_SECURE_SETTINGS only does anything for system apps), and then the code that was only available to system apps is now available to yours as well.
For reliability, you should use shell commands where possible for anything that's normally unavailable. Do not use java.io.File to access files that are normally restricted.
I would recommend using RootTools as it makes running shell commands as root much easier. The first 3 pages on this linux command cheat sheet will probably cover everything you need.
I'm working in eclipse and trying to use my phone (HTC Thunderbolt) for development for the first time (because the emulator is too slow).
In Eclipse I get the error:
Android ActivityManager: am: not found
(The error is after Android Launch!, adb is running normally, and Success!, etc.)
Using adb shell, I see that the am file is not located in /system/bin or anywhere else that I looked. I'm running a custom ROM on my phone. Is it possible the file is simply not present? If so, can I push it to my phone? How?
Thank you
EDIT: Using adb shell, from /, I ran ls -R | grep "^am$" and there is no file named "am".
I have seen posts like this one where they mention an error message like system-bin-sh-am-not-found, but in those cases the file is actually present and needs to be edited. In my case, the file is not present. Anyone have a copy of /system/bin/am for Gingerbread? Is it the same for all devices?
Look into your bin folder, there should be a file named after your project followed by .apk
example. project name = mountainx, the file is mountainx.apk
copy that into your handphone storage, then install it from your phone via application installer or any other applications that can access the apk file
The problem was related to the custom ROM I was running. The ROM cook had not included that file in the ROM.
I have an xml file being written by an app that is set to MODE_PRIVATE, but I now want to read that file outside of the phone, for debugging purposes. In Eclipse, I can access other files made by the app and copy them to my computer, but I can't even see this private file. Merely changing the file to MODE_WORLD_READABLE file doesn't seem to help. I think the file is being stored on an internal "SD card" that can not be removed from the phone, but there are also two other folders in the File Explorer that are either empty or inaccessible: asec and secure.
Does anyone know how the file can be accessed?
If your app is installed in debug mode, you can get your private files on a device without rooting.
Go to [android-sdk]/platform-tools folder and run adb shell.
run-as com.example.yourapp
cp -r /data/data/com.example.yourapp /sdcard/
(Where com.example.yourapp is the package name of your application.)
After executing the steps above, the private folder of your application is copied into the root of your sdcard storage, under your package name, where you have permission to download and view them.
Note 1: If you don't need to download them, then instead of step 3, you can use unix commands to navigate around and list files and folders.
Note 2: Starting from Android Studio 2.0, you'll find more files in the cache and files/instant-run folder, related to the Instant Run and the GPU Debugger features, placed there by the IDE.
You will need to connect the phone and do some magic to let your sdk work with it (I think put it in debugging mode?). Go to where you unzipped the android sdk:
C:\android-sdk_r10-windows\android-sdk-windows\platform-tools>adb shell
#cd data/data/com.yourpackage.yourapp/files
#ls
You should see your file listed. You may need to run "ls data/data" if you're not sure what the fully-qualified name of your app is. From here if the file is small and you just want to see what's inside it you can run:
#cat yourfilename.xml
Alternatively:
#exit
C:\android-sdk_r10-windows\android-sdk-windows\platform-tools>adb pull /data/data/com.yourpackage.yourapp/files/yourfile.xml
Note: I have only tried this on the emulator, I don't know how to use adb with a physical phone.
You need to root your phone to see Context.MODE_PRIVATE files
It ends up being stored in data//files I believe but you need root permission to see them
So either root your phone or wait until you finished debugging and then add Context.MODE_PRIVATE
If Eclipse is used, there is one more option:
DDMS Perspective > File Explorer tab > data/data/com.yourpackage.yourapp/files
where you can pull/push/delete files.
Another option is to have a command in the app that dumps the private files. This only works if you don't want to edit the files, but has the added bonus that you don't have to strip it out before it goes to production, because the user can't break anything with it. Well, as long as the files don't contain sensitive information. But, really, if they do, you're doing something wrong. As #user1778055 said, a user can root their phone to access it.