Browse SQLite database from Android Studio

46,872

Solution 1

UPDATE July 2020

With Android Studio 4.1 (Canary 6 and higher), you can inspect, query, and modify your app's databases using the new Database Inspector.

You can find the official doc here.


Currently there isn't an official plugin for DB Inspection in your apps.

  • You can use the DDMS : Tools > Android > Android Device Monitor as described in @Subhalaxmi's answer

  • There is a beta plugin provided by idescout that you can try here.

  • There is the Stetho tool (open source and free) provided by Facebook

I suggest you using the Stetho open-sourced tool provided by Facebook. It is simple to implement and very powerful.

Just add the dependencies in your build.gradle

dependencies {
    // Stetho core
    compile 'com.facebook.stetho:stetho:1.3.1'       

    //Optional network helper
    compile 'com.facebook.stetho:stetho-okhttp:1.3.1'       
}

Then just initialize the tool in your Application class:

Stetho.initialize(Stetho.newInitializerBuilder(this)
        .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
        .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
        .build());

Finally just open Chrome on your pc and navigare in chrome://inspect.

Here you can display the database in the app (with read/write capabilities), and you can run queries.

enter image description here

You can find more info about Stetho here:

Solution 2

Install Sqlite

Open DDMS : Tools > Android > Android Device Monitor

Click on your device on the left.

You should see your application:

Go to File Explorer(one of the tabs on the right), go to /data/data/databases and select your application package

Ex: check image

enter image description here

Select the database by just clicking on it.

Go to the top right corner of the Android Device Monitor window.

Click on the pull a file from the device button:

enter image description here

A window will open asking you where you want to save your database file.Save it anywhere you want on your PC.

Now, open the SQLiteBrowser you installed. Click on open database, navigate to the location you saved the database file, and open.You can now view the contents of your database.

Solution 3

I'm using TKlerx/android-sqlite-browser-for-eclipse for instant browsing inside Android Device Monitor. I found it the fastest and most practical way.

Just download the jar from the releases page and place it in the [android-sdk-folder]/tools/lib/monitor-x86_64/plugins.

Afterwards, just browse any database file inside the File Explorer and click the blue-ish icon shown in the picture:

enter image description here

Enjoy !

Solution 4

There is no such feature or plugin for Android Studio at least now.

Check out stetho - one of features of this library is to provide a bridge to view your device database contents directly from Chrome Developer Tools in desktop Chrome browser.

Solution 5

You should go to Tools>Android>Android device monitor it would then launch the android device monitor Then you should navigate to the file explorer in the Android device monitor and then navigate to the database where you have saved it in the device and then use the option pull a file from a device. and save the database file where ever you want and if you want to open and view the data in it use the following link

SqLiteBrowser

Share:
46,872
Mohamad Arafat
Author by

Mohamad Arafat

I am a computing student.

Updated on September 12, 2020

Comments

  • Mohamad Arafat
    Mohamad Arafat over 3 years

    I would like to know is there any SQLite plugin for Android Studio which will allow user to browse the created database?