TRANSFERRING FILES INTO AND OUT OF THE EMULATOR

Occasionally, you may need to transfer files into or out of the emulator. The easiest way is to use the DDMS perspective. From the DDMS perspective, select the emulator (or device if you have a real Android device connected to your computer) and click the File Explorer tab to examine its file systems (see Figure B-25).

The two buttons highlighted in Figure B-25 enable you to either pull a file from the emulator or push a file into the emulator.

Alternatively, you can also use the adb.exe utility shipped with the Android SDK to push or pull files to and from the emulator. This utility is located in the <Android_SDK_Folder>platform-tools folder.

To copy a file from the connected emulator/device onto the computer, use the following command:

      adb.exe pull /data/app/<filename> c:
image

NOTE When using the adb.exe utility to pull or push files from or into the emulator, ensure that only one AVD is running.

Figure B-26 shows how you can extract an APK file from the emulator and save it onto your computer.

To copy a file into the connected emulator/device, use the following command:

adb.exe push NOTICE.txt /data/app

The preceding command copies the NOTICE.txt file located in the current directory and saves it onto the emulator’s /data/app folder (see Figure B-27).

If you need to modify the permissions of the files in the emulator, you can use the adb.exe utility together with the shell option, like this:

adb.exe shell

Figure B-28 shows how you can change the permissions of the NOTICE.txt file by using the chmod command.

Using the adb.exe utility, you can issue Unix commands against your Android emulator.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset