Sometimes while developing applications we need to see the database. Android has SQLite Database and in Android Studio there is no direct option to view the database. So today we will be learn accessing SQLite Database using ADB Shell. So if you are wondering How to Access SQLite Database in Android then keep reading.
Android SQLite Tutorial
- If you want to learn how you can handle SQLite Database in your Android Application, then just go through this playlist for a detailed explanation.
How to Access SQLite Database in Android?
Just follow these steps and you will be able to access and run queries for your SQLite database using command prompt.
Finding SDK Location
- First you need to find the SDK Location of your system. For this go to File -> Settings.
- Now you can see the SDK Location in the window.
- Copy the path.
Going to the SDK Location in Command Prompt
- Now open command prompt and write the following command.
- Again run the following command.
- Now you are inside the directory platform-tools.
Enabling ADB Root
- To access database we have to enable adb root. For this simply run the following command.
- Now we will list out all the running emulators and devices. For this run the following command.
- It will show you all the running devices.
- As you can see I have only one devices for now.
Connecting with Device Shell
- Run the following command to connect a shell to your device.
adb -s emulator-5554 shell
- Dont forget to change the emulator’s name in the above command.
- And after running the command you will be connected to the device.
Going to Database Folder of the Device
- Run again the following command to access database folder.
- Don’t forget to change net.simplifiedcoding.androidmysqlsync with the package name of the application that you want to access.
Connecting to SQLite Database
- To connect to SQLite Database run the following command.
- In the above command NamesDB is my database name you have to change it with your database name.
- Bingo! We are connected with the database.
- Now you can run the command .help for the SQLite Cheat Sheet to view or modify databases.
So this is how you can easy your work of SQLite in Android. If you are having any confusions or troubles feel free to leave your comments. Thank You 🙂
Hi, my name is Belal Khan and I am a Google Developers Expert (GDE) for Android. The passion of teaching made me create this blog. If you are an Android Developer, or you are learning about Android Development, then I can help you a lot with Simplified Coding.