Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Genymotion. How to pull database from device. my /data/data/ folder appears to be empty

I have an issue with my Ubuntu installation of genymotion. Mainly I am unable to debug my database since both through DBMS in eclipse and adb in shell I can not view content of /data/ folder. There are no files shown.

I log through adb by cd to /sdk/platform-tools and typing ./adb shell su . I see that tab is not working, so I blindly type the path. Anyways I am not able to pull db, maybe I'm doing something wrong with commands.

Through DBMS i try to connect but data folder does not display content.

On Emulator everything works smoothly, but emulator is slow and I would rather use genymotion.

Any suggestions how to deal with this problem?

like image 514
RafalManka Avatar asked Aug 10 '13 22:08

RafalManka


3 Answers

I don't have the problem you are talking about, the default shell user on Genymotion is root, so it should not happen. Despite everything, you can use run-as command to access your data directly.

To make it short. Your app's data folder is protected by your app's user rights. The default shell user don't have right access to the app's folder. You can change the user that the shell is using thanks to the run-as command.

  1. Open a shell: adb shell
  2. Then type: run-as your.package.name

This command will change the shell user to the user of your app. So you will have the right to read and write on the app's data. You will also be redirected to your app's data folder: /data/data/you.package.name

When it is done you can browse your files easily.

Notice: Your app has to be built as debug to be able to use this command. It is supposed to be displayed on the device processes list on DDMS.

like image 161
eyal-lezmy Avatar answered Nov 15 '22 16:11

eyal-lezmy


Run emulator on your local computer, then

localuser:~ localhost$ adb shell
shell@android:/ $ su
shell@android:/ # cp /data/data/your.package.name/databases/your_database.db /mnt/shell/emulated/0/Download/your_database.db
shell@android:/ # exit
shell@android:/ $ exit
localuser:~ localhost$ adb pull /mnt/shell/emulated/0/Download/your_database.db ~/your_database.db

What it does is:
1. Connects to the emulator
2. Requests superuser permissions
3. Copies the file that is only available to superuser to a public directory (Downloads in this case)
4. Pulls the file from public folder (Downloads) to your local machine home directory; you can also perform this step from eclipse gui.

like image 7
Alexey Avatar answered Nov 15 '22 16:11

Alexey


You've to set permissions to that folder / file, then you can pull easily:

adb shell "run-as package.name chmod 666 /data/data/package.name/databases/file"

adb pull /data/data/package.name/databases/file .

like image 2
Reinherd Avatar answered Nov 15 '22 18:11

Reinherd