All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

How To View SQLite Database In Android Studio

Last Updated : Mar 11, 2024

How To View SQLite Database In Android Studio

In this article we will show you the solution of how to view SQLite database in android studio, when your app is operating, you may look within, query, and change its databases using the Database Inspector.

This is extremely helpful for debugging databases. The Database Inspector supports both standard SQLite and libraries that are based on SQLite, like Room.

The list of databases inside your programme, together with the tables each one contains, are shown in the Databases pane.

To see a table's data inside the inspector box on the right, double-click the name of the table. The data inside this inspector window can be sorted by any column by clicking its heading.

Choose the Live updates checkbox just at the inspector window's top to allow the Database Inspector to update automatically the data it displays as you work with your running application.

The table inside the inspector window was read-only and you cannot change its values when live updates are enabled.

A Refresh table button is located at the top of an inspector window and can be used to manually refresh the data.

Your Database Inspector has the ability to make database queries while your app is in use.

If your app utilizes Room, this tool could use DAO queries, but it also allows bespoke SQL queries.

If your app makes use of Room, Android Studio has gutter actions that enable you to swiftly execute query methods you've already created on your DAO classes.

While your project is running as well as the Database Inspector was open in the IDE, these actions are accessible.

Step By Step Guide On How To View SQLite Database In Android Studio :-

package com.talkerscode.database;
public class Product {
    private int _id;
    private String _productname;
    private int _quantity;
    public Product() {
    }
    public Product(int id, String productname, int quantity) {
        this._id = id;
        this._productname = productname;
        this._quantity = quantity;
    }
    public Product(String productname, int quantity) {
        this._productname = productname;
        this._quantity = quantity;
    }
    public void setID(int id) {
        this._id = id;
    }
    public int getID() {
        return this._id;
    }
    public void setProductName(String productname) {
        this._productname = productname;
    }
    public String getProductName() {
        return this._productname;
    }
    public void setQuantity(int quantity) {
        this._quantity = quantity;
    }
    public int getQuantity() {
        return this._quantity;
    }
}
  1. First we create package as talkerscode database.
  2. Then we create a class as a product.
  3. Then we create a private integer, product name, quantity.
  4. After that we defined all values of products.

Conclusion :-

Your query results which are shown in the Create Query page can only be read; they cannot be changed.

But, you can execute modifier statements like UPDATE,INSERT, or DELETE using a custom SQL query field.

All modifications you make to a data were immediately visible within your running app if your programme uses Room & your UI monitors the database, just like with LiveData or Flow.

If not, changes won't be shown until your programme retrieves the updated data from the databases the following time.

I hope this article on how to view SQLite database in android studio helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Amruta

Amruta is an Experienced web developer with 4 years for experience she completed her master's with MCA and passionate about programming Languages for creating technical contents like HTML, CSS, JavaScript, Java, Python, PHP, jQuery.

Follow Amruta On Linkedin 🡪