Any development work invariably involves the use of terminals. There are many who find the terminal much more fascinating than the GUI. This post is mainly targeted towards those. However, those who are not so much into command user interface, also need to take a look.
ADB exapanded as Android Debug Bridge is a versatile command line tool. It lets your system interact directly with an Emulator instance’s or a tethered Android device’s file system. Remember that this can be done on the device or the emulator itself using a terminal emulator, but writing and executing commands on the device becomes quite a task.
ADB comes with the Android SDK and no separate installation is required. It is located in <your android sdk> -> platform-tools -> adb.exe.
To get started with ADB we need to launch it first. Below instructions are for Windows Users.
- Open up Run on Windows by pressing Windows+R.
- Type in cmd to launch the Command Prompt.
- Now navigate to your Android SDK directory using the cd command. For instance, my SDK is located in G:\Android Development\
So I type in:
cd Android Development
- Furthermore, in order to navigate to platform-tools I type in:
- Type in the below command:
- The above command gives a detailed summary of the components present in the ADB. It’s quite a read so you can spare some time to have a look.
- Now type in the following command:
- You are now inside the ADB shell. Here you can type and execute ADB commands. Start an emulator and after it has successfully started, execute the below command:
- This shows the list of all running emulators and tethered Android devices. Remember that in some cases you might need to turn on USB Debugging in your Android device for it to be recognized by the ADB.
- You can practically control your device from this terminal.
Now that you have a fair idea of what ADB is and what it is used for, it is time you try out some commands on your own. You can start off by reading the official Android Documentation for ADB here.
The post should act as a precursor to what we are going to do next, which is to use ADB shell for SQLite queries on our Application databases. In the part II of this post I will show you how we can stop relying on logs to see the data in our application’s database and make use of ADB shell instead, to do this in a simpler and effective manner.