Different Ways to View Contents of Database File in Android Studio
Last Updated :
06 Apr, 2021
Data is a group of information and it can be any kind of information – text, numbers, image, video. An organized collection of this data is called a Database. It is made so that the data can be accessed and managed easily. Data can be organized into tables, rows, columns as that make it easier to handle the data. The main purpose of having a database is to make it possible to work with huge amounts of data and be able to handle it. Databases store all the data that is required or was used in history by the website or app. There are a number of databases available, such as MySQL, Sybase, Oracle, MongoDB, Informix, PostgreSQL, SQL Server. A database management system (DBMS) is used to manage modern databases. Structured query language (SQL) is used to perform operations on the data stored in the database. There are many ways to view the content of databases in Android Studio. In this article, we are going to discuss five different methods to View the Contents of the Database File in Android Studio.
- Method 1: Without Opening DDMS
- Method 2: Using Stetho library
- Method 3: Using SQLiteBrowser
- Method 4: Using ADB shell to connect to Sqlite3
- Method 5: Using Database Inspector
Method 1: Without Opening DDMS
This method works on the Emulator only.
In the first step, note down the path of the database file in your system. For example, let it be
/data/data/com.VVV.file/databases/com.VVV.file.database
Secondly, the database file needs to be pulled into the PC. Use the following command
adb pull /data/data/com.YYY.module/databases/com.YYY.module.database /Users/PATH/
If it shows permission denied or something similar to it, run adb root and run the previous command again.
Method 2: Using Stetho library
In the first step – add stello dependency in build.gradle
compile 'com.facebook.stetho:stetho:1.5.0’
The second step – put the following command on the OnCreate() method of the main activity
Stetho.initializeWithDefaults(this);
The third step – Connect a device and run the app. Visit the following site using Chrome browser
chrome://inspect/#devices
Method 3: Using SQLiteBrowser
Download and install SQLiteBrowser. Copy the database from the device to the PC
- For Android studio versions < 3.0
- Open DDMS via Tools > Android > Android Device Monitor
- The device should appear on the left, click on it.
- All the applications running on the device will appear.
- A tab on the bottom right corner appears named File explorer
- In the file explorer, go to /data/data/databases
- Select the database you want to see.
- Click on the ‘pull a file from the device’ button. It is present in the top right corner of the Android device monitor window.
- A pop-up window will ask to save the files. Save them wherever you want to.
- For Android studio >= 3.0
- Use View > Tool Windows > Device File Explorer to Open device file explorer.
- Go to data/data/PACKAGE_NAME/database. PACKAGE_NAME is the name of the package one is developing.
- Right-click on the database and save it wherever you want using the Save As.
Open the SQLiteBrowser and click on ‘open database’. Navigate to the place where the database was saved and open the database. The content of the database is displayed now.
Method 4: Using ADB shell to connect to Sqlite3
Go to the tools folder in the command prompt. Use the command adb devices to see the list of all devices
C:\ProgramFiles(x86)\Android\adt-bundle-windows\sdk\platform-tools>adb devices
List of devices attached
Redmi Note 7 pro device
Connect a shell to the device
C:\ProgramFiles(x86)\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb -s Redmi Note 7 pro shell
Go to the file containing the DB file
cd data/data/<package-name>/databases/
Execute sqlite3 to connect to DB
sqlite3 <db-name>.db
Run SQL commands to see any table. For example:
Select * from table1;
Method 5: Using Database Inspector
In the latest version of Android studios 4.1, the long-awaited tool Database Inspector made its appearance. It helps to inspect, query, and modify the database in the running app. Database inspector makes database editing as simple as editing a spreadsheet. Using room and observing the query result the changes are reflected in real-time in the app.
- To open the database inspector select View -> Tool Windows -> Database Inspector from the menu bar of Android Studio.
- Connect a device running on API level 26 or higher.
- Run the app.
- The database schemas appear and you can select the database you want to see.
- The selected database is displayed.
Similar Reads
Different Ways to View Contents of Database File in Android Studio
Data is a group of information and it can be any kind of information - text, numbers, image, video. An organized collection of this data is called a Database. It is made so that the data can be accessed and managed easily. Data can be organized into tables, rows, columns as that make it easier to ha
4 min read
Different Ways to Create aar File in Android Studio
Android Studio can be used to create an Android archive file (*.aar) that can contain classes and methods that make use of Android classes and related files. Like creating the Jar file, an Android project must be created first, then the Android library module can be created and added. The main diffe
3 min read
Different Ways to View Method Information in Android Studio
Easy access to documentation written in comments when hovered over the text is like a cherry on a cake. In Android Studio and other JetBrains editors, there is an option that you can enable to display function types and docs on mouse hover. But first, let's get familiar with what methods are in Andr
3 min read
Different Ways to Delete a Module in Android Studio
We all know that Android Studio is one of the most famous IDE (Integrated Development Environment) out there. It is available for download on Windows, macOS, and Linux-based operating systems or as a subscription-based service in 2020. It is a replacement for the Eclipse Android Development Tools (E
3 min read
Different Ways to Change the Project Name in Android Studio
When you have worked a lot on an Android project and then if you need to rename the project there are lots of configuration files, .xml files, and gradle files in Android Studio that youâre afraid to break things up. Sometimes we end up creating a new Android Studio project, with the correct name an
2 min read
How to View and Locate SQLite Database in Android Studio?
SQLite is an open-source relational database that is used to perform database operations on android devices such as storing, manipulating, or retrieving persistent data from the database. In this article, we will learn how to view and locate SQLite database in Android Studio using device file explor
2 min read
How to View and Locate Realm Database in Android Studio?
Realmâs mobile database is an open-source, developer-friendly alternative to CoreData and SQLite. Realm Database is a service which is provided by MongoDb which is used to store data in users device locally. With the help of this data can be stored easily in users' devices and can be accessed easily
2 min read
Different Ways to Analyze APK Size of an Android App in Android Studio
APK size is one of the most important when we are uploading our app to Google Play. APK size must be considered to be as small as possible so users can visit our app and download our app without wasting so much data. In this article, we will take a look at How we can analyze our APK in Android Studi
3 min read
How to Create a New Fragment in Android Studio?
Android Studio is the official integrated development environment for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. You can Develop Android App using this. Here, We are going to learn how to create a new Fragment in A
2 min read
Different Ways to Increase Editor Font Size in Android Studio
Android Studio is the official IDE (Integrated Development Environment) for Android app development and it is based on JetBrainsâ IntelliJ IDEA software. Android Studio provides many excellent features that enhance productivity when building Android apps, such as: A blended environment where one can
2 min read