Mobile devices especially Android and iOS stores a variety of information in Database (db) files. A Database file may contain information about SMS, contacts as well as other device and app data. These type of files stores large amounts of data, mostly by connecting the data to tables, rows and columns.
These files are also locked or encrypted. Although they are commonly saved in SQLite database format, it can not be accessed easily.
On your mobile device these files are not meant to be opened or edited because they are support files for the effective running of your device, There are different methods to open a database (db) files on Android if you want to either as a developer or an Android user. This article will discuss these methods with guidelines.
Steps On How To Open db Files Android
1. Open db Files Using SQLiteBrowser
First off, Download and Install SQLiteBrowser. Then Copy the database to the PC from your device. Then proceed to the next step; For Android studio version 3.0:
- Open DDMS via tools
- Go to Android> Android device monitor
- When the device appears in the left, click on it
- All running applications in the device will appear
- Click on file explorer at the tab on the bottom right corner
- Go to data/data/databases
- Select which database your want to open
- Click on “Pull file from the device” button at the top right corner of the Android device monitor window
- A pop up window will ask you to save the files
- Save
For Android studio 3.0:
- Use View> Tools Windows
- Go to Device file explorer to open device file explorer
- Then go to data/data/PACKAGE_NAME/ database NB:PACKAGE_NAME refers to the name of package you are developing
- Right click the selected database and click Save As
- Save it wherever you want to
Then open SQLiteBrowser and click “Open database” Navigate to the place you saved the database to , open it and see displayed contents.
2. Open db Files Using ADB Shell To Connect To SQLite 3
In the command prompt, go to tools folder. Then use the command ADB devices to see a list of all devices.
- C:\ProgramFiles(x86)\Android\adt-bundle-windows\sdk\platform-tools>adb
- List of devices attached
- Hot 8 Lite Device (your device name)
- Next, Connect the shell to the device
- C:\ProgramFiles(x86)\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb
- Then go to the file containing db files
data/data/<package-name>/databases/ - Execute SQLite 3 to connect to db. Run SQL commands to see any table.
sqlite3 <db-name>.db
3. Use Database Inspector To Open db Files On Android
Database Inspector helps to inspect, query and modify the database in the running app. It makes database editing very easy almost like editing a spreadsheet.
To open using this method;
- Select View> Tools Windows> Database Inspector from Android studio menu bar
- Connect a running device in API level 26 or higher
- Run the app
- The database schema will appear, select the database you want to see
- It will be displayed for you to see.
4. Open db Files Using Stetho Library
- Firstly, add stello dependency in build.gradle
compile ‘com.facebook.stetho:stetho:1.5.0’ - Second step, put the command on the OnCreate()method of the main activity
Stetho.initializeWithDefaults(this) - After that, run the app on a connected device. After that, proceed to this site with your chrome browser: chrome://inspect/#devices
5. Open db files on Android without opening DDMS
This particular method only works in Emulator
- Firstly, note down the path of the database file in your system Take for example below;
data/data/com.VVV.file/databases/com.VVV.file.database - Once you have noted down the path, pull the database file into the system using the command below;
adb pull /data/data/com.YYY.module/databases/com.YYY.module - If it shows permission denied, or something like that. Then you have to run adb root and run the previous command again.
These above methods discussed will enable you open db files on Android.