My android app creates an sqlite database and I need to get it off the device so I can look at the data with a database viewer.
Was hoping I could just issue >adb shell and then go find it somewhere on the file system. Looks like there are permission issues with lots of commands. Even just running >find . -name *.sqlite gives permission denied.
Can anyone advise on how to do this?
It seems your device is not rooted, anyway..
Copy your .db file form /data/data/<package_name>/databases/ to ExternalStorage using code.. Then you can get it via adb pull command or DDMS -> FIle Explorer.
Currently there is no way to browse database on the device (without getting the root permission as you want) .
You can browse your database from emulator using adb shell.
Related
I created my first Android App with SQLite and tested it on my phone.
Now I installed an SQLiteManager on the phone and I would like to open the SQLitedatabse file.
The location is /data/user/0/com.<appname>/database/database.db
But this folder does not exist. How can I find and access the database file?
And I am also not able to find the apk of my App. In Android/data/ I can see all other installed apps, but not my own app.
How can I find yout where it is located?
The acutal path is /data/data/package.name/database.
If your app is in debug mode, most newer devices allow accessing this folder via Android Studio (or adb run-as). On the emulator this folder is public.
Just run the command in terminal
adb pull /data/data/com.example.myapplication/databases/your_db.db
No need to root your device.
I used this way on Mac with Terminal:
sudo adb -d shell "run-as com.YOUR_COMPANY.YOUR_APP_NAME cat databases/YOUR_DATABASE_NAME.db" > NEW_NAME_FOR_DATABASE.sqlite
Sometimes you need first to give that file a permission 666, so you can copy it to your computer.
chmod 666 YOUR_DATABASE_NAME.db
Your device must be Rootable for you to be able to see the .DB file
for the second question, try to search for your package name first. Maybe it's like xxx.xxx.Christina.xxx.AppName ?
HI I am developing an android application for android on nexus 7 device.
I am trying to copy my database.db from assets to /data/data/myPackage/databases/ folder. Nothing wrong till here. No exceptions and everything runs smoothly.
But When i try to get into /data/data/ folder through adb shell or with file explorer it says permission denied or just doesnt show anything.
Am I missing something here ?
PS: myPackage is just symbolic i have my own package name in its stead
Command line is here
shell#tilapia:/ $ cd /data/
shell#tilapia:/data $ ls
opendir failed, Permission denied
You need to have your device rooted to be able to access that folder.
If you want to look at your database you can always export it to the sdcard and look at it there.
see this link for an example on how to do that
trying to export db to SDCARD
you can always get the db out of the emulator, but never from a live device or else it would be easy to write apps that read/write other apps' databases and create malware
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 would like to edit my app's DB using the SQLite Browser. I'm able to edit the DB using the adb shell (sqlite3), but I would rather edit it using a GUI rather than a command line. How do I get the DB from the emulator to a local drive? As of now I've tried:
1) using the adb pull command to pull the database from the emulator to my local drive.
adb pull data/data/com.myapps.quiz c:/
This command executes correctly, but I'm not able to find the file or directory in the local drive I specified.
2) Used the DDMS Perspective to locate the file in the File Explorer, but every time I get into the data/data directory, I only see directories called "con". I even tried pulling the entire data/data directory, but I can't find the name of the package (com.myapps.quiz) where the database is stored.
What am I missing here? Any help you could provide would be most helpful!
Your database is secure to your package so you cannot get this directly.
I have a work around for this.
What I do is go to shell and run-as my package and copy the database to sdcard using cat
adb shell
run-as your.package.name
cd databases
cat your_database.db > /mnt/sdcard/your_database.db
And I pull the file from the sdcard using File Explorer
Are you sure you're connecting to the emulator instance in DDMS, and not an actual device? I have always been able to push and pull sqlite databases from the
data/data/com.my.package/databases/mydb.sqlite
directory, and I can't think of any setting that would override that. An alternative would be to root an actual phone and then you will be able to move anything from the phone to your computer.
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.