http://developer.android.com/guide/developing/tools/adb.html
Issuing adb Commands
You can issue adb commands from a command line on your development machine or from a script. The usage is:
adb [-d|-e|-s <serialNumber>] <command>
Querying for Emulator/Device Instances
Before issuing adb commands, it is helpful to know what emulator/device instances are connected to the adb server. You can generate a list of attached emulators/devices using thedevices
command:
adb devices
The output for each instance is formatted like this:
[serialNumber] [state]
- Serial number — A string created by adb to uniquely identify an emulator/device instance by its console port number. The format of the serial number is
<type>-<consolePort>
. Here's an example serial number:emulator-5554
- State — The connection state of the instance. Three states are supported:
-
offline
— the instance is not connected to adb or is not responding. -
device
— the instance is now connected to the adb server. Note that this state does not imply that the Android system is fully booted and operational, since the instance connects to adb while the system is still booting. However, after boot-up, this is the normal operational state of an emulator/device instance.
-
Directing Commands to a Specific Emulator/Device Instance
If multiple emulator/device instances are running, you need to specify a target instance when issuing adb commands. To so so, use the -s
option in the commands. The usage for the -s
option is:
adb -s <serialNumber> <command>
Installing an Application
You can use adb to copy an application from your development computer and install it on an emulator/device instance. To do so, use the install
command. With the command, you must specify the path to the .apk file that you want to install:
adb install <path_to_apk>
Copying Files to or from an Emulator/Device Instance
You can use the adb commands pull
and push
to copy files to and from an emulator/device instance's data file. Unlike the install
command, which only copies an .apk file to a specific location, the pull
and push
commands let you copy arbitrary directories and files to any location in an emulator/device instance.
To copy a file or directory (recursively) from the emulator or device, use
adb pull <remote> <local>
To copy a file or directory (recursively) to the emulator or device, use
adb push <local> <remote>
In the commands, <local>
and <remote>
refer to the paths to the target files/directory on your development machine (local) and on the emulator/device instance (remote).
Here's an example:
adb push foo.txt /sdcard/foo.txt
Listing of adb Commands