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
Related
I'm debugging my android app in Android Studio using a real android device and. I see that the Sqlite db path is
/data/data/com.my_app/databases/data1.db
I want to remove it. By that path doesn't exist when try to find it by a file manager. And, of course, this isn't working:
adb -e shell rm /data/data/com.my_app/databases/data1.db
adb server is out of date. killing...
* daemon started successfully *
error: device not found
So how can I remove it and why isn't it visible in my smartphone?
why isn't it visible in my smartphone?
Because it is on internal storage, which you do not have access to, except on emulators and rooted devices.
And, of course, this isn't working:
That is some separate problem with adb running on your machine.
So how can I remove it
If you want to completely clear your app's data (databases, SharedPreferences, and other files) on internal storage, use the Settings (e.g., Settings > Apps > (your app) > Clear Data on Android 4.x/5.x).
If you specifically want to get rid of this file on an emulator, the command you tried should be fine. I suggest restarting the emulator.
If you specifically want to get rid of this file on production hardware, you will need to use run-as:
adb shell run-as com.my_app rm /data/data/com.my_app/databases/data1.db
You can't reach that directory if your device isn't root . For change or modify system files you must have root access .
I pulled out a file from the android sdcard using adb and it seems it goes to c:\documents and settings\userName by default. I don't know how it got set to this folder since this is not where adb is installed, but probably has got something to do with the fact that both the workspace and .android folders are located here. How do I change this default location for pull command of adb?
The default directory for adb pull or adb push seems to be the current directory (aka . ).
If you issue a command such as the following, not specifying the target directory
adb pull /boot.txt
the file (provided it exists) will be copied to the current directory.
Windows users:
Take notice of the following: If you are using Windows (Vista or newer), chances are that if the current directory requires elevated privileges to write on, Windows will silently replicate the directory structure of your current directory in a special folder called VirtualStore and will copy your files in it.
The full path for VirtualStore is: %LOCALAPPDATA%\VirtualStore, which most likely will translate into C:\Users\<account_name>\AppData\Local\VirtualStore.
So, in the following scenario,
C:\> cd "C:\Program Files (x86)\MyCustomADBInstallLocation"
C:\Program Files (x86)\MyCustomADBInstallLocation> adb pull /boot.txt
your file boot.txt will end up in this folder
C:\Users\<account_name>\AppData\Local\VirtualStore\Program Files (x86)\MyCustomADBInstallLocation\
you can mention the destination location for adb push/pull, see example:-
adb push a.txt /data/local
adb pull /data/local/a.txt .
. means present directory.
or
adb pull /data/local/a.txt C:\
Hope this helps.
i'm using linux, and noticed that if i opened the terminal as root, its opened # home. when i pull items, it dumps to that repository, meaning to my "home" directory. will try opening terminal in a different folder and running adb pull from there to see if that makes the files dump to the folder terminal is opened in.
i am trying to see SQLite database in anyway possible (I have a rooted device). I tried File explorer in eclipse but i cannot see anything under data folder. Can anybody please help me with this
I tried to search everywhere but couldnt find a clear solution.
I also tried adb shell but i cannot see list of things inside data folder using "ls" command.
error
Opendir failed. Permission denied
I am guessing this has something to do with rights but how can i fix it
Please help
You need root premission to explore DATA directory...
From phone
I use terminal emulator to do the job..... Simply open terminal then type in su after that it will ask for premision. then you need to type cd data/data/WhereEverYouNeedToGo/databases and "WhereEverYouNeedToGo" should be package name. After that you could do whatever you want with your database.
from PC
open terminal or cmd goto your adb directory then run adb shell then su and then
cd data/data/WhereEverYouNeedToGo/databases
Hope it helped.
Run adb in root mode using "adb root"
adb shell
su
ls /data/
Try this
You have been given a number of answers for how to leverage the root capability, however as android is designed without the assumption of root there are other methods as well which you can use while developing apps.
1) Include functionality on an expert menu to copy the database to the sdcard; there is no file copy method in android java (and in most stock cases no 'cp' shell command), but you can find numerous answers here with a copy routine.
2) Make your apk debuggable and use the run-as command to obtain a shell running as the application userid and starting in the app's data directory. You can then copy the database to the sdcard if the app has that permission.
3) Have your app set the permissions on the database file during development to world readable. Although you cannot browse the directory tree to down to it, you can then adb pull the database file by giving it's full path name.
You need to have either routed device or your device should be a "Android Dev Phone" to explore that directory. Trying checking the same using emulator, you will be able to see the data folder contents.
I have created a database for my app and I want to check .db folders to check the data inserted while developing. But my Android mobile will not allow to access data folder. To achieve this I have rooted my mobile with GingerBreak.apk. Device rebooted but nothing happened. How can I check my data base from my phone.
Note: I can't check the data using emulator, because app cant run on emulator, it uses, Bluetooth, WiFi,etc.
Regards,
Krishna
You need to install some file broswer(such as R.E file manager) to access to these .db files. They are located in /data/data/{package name} dir.
Meanwhile, you can access these file via command line.
For emulator:
Type adb shell in the command line, and you can see a "#" prompt.
Type 'cd /data/data/{package name}` to go to the very dir where the
.db file is located.
Now type sqlite3 <db file name, no extension> so that you can execute SQL command to read and control the .db file. Now you can see a "sqlite>" prompt.
For real device(phone must be rooted):
Step 2 and 3 are the same. In Step 1, you have to type "adb shell", and then "su" to see the "#" prompt.
Hope it helps.
To root your phone. You can use lucky patcher app.Although there are plenty of apps available around internet but i found it worth using
By using this app you can not only root your device as well as remove annoying ads and much more.
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.