View of SQLite database in Android

Source: Internet
Author: User
Tags sqlite database

When the SQLite database is created, how do you view the contents of the database? If you use File Explorer directly, you can only see a bookstore.db file that appears under the database directory, and the Book table cannot be seen through the file explorer.

I will briefly describe how two SQLite databases are viewed to check the creation of databases and tables.

-----------------------------------the Database visualization tool ------------------------------------------

First download a Sqlitestudio tool:

Next, export the Bookstore.db file under the/data/data/< package name >/database/directory:

Add the exported bookstore.db to the Sqlitestudio:

Open the Bookstore database and you can view and edit the Book table:

You can also import it back into your phone after editing is complete.

Although this method is simple, it is more troublesome, and each check requires a re-export of the file. Suitable for use when viewing data, and not for use when debugging a database.

-----------------------------------the command-line utility ------------------------------------------

ADB is a debugging tool that comes with the Android SDK, which allows you to debug a phone or emulator connected directly to your computer. It is stored in the Platform-tools directory of the SDK, and if you want to use the tool on the command line, you need to configure its path to the environment variable first.

Configure environment variables under Windows system:

Once you have configured the environment variables, you can use the ADB tool.

Open the command line interface, enter the ADB shell and enter the device console:

/*Enter the ABD shell into the device console*/C:\Users\dudon>adb Shell/*use the CD command to enter the database storage directory*/[email protected]:/# cd/data/data/com.example.dudon.databasetest/databases//*use the LS command to view files in this directory*/[email protected]: # lsbookstore.db/*db-journal is a temporary log file that is created to enable a database to support transactions*/bookstore.db-Journal/*using the SQLite command to open the database, enter sqlite3 plus the database name to*/[email protected]: # sqlite3 bookstore.db<SQLite version3.7. One  --Geneva- -  One: *: -Enter". Help"  forInstructionsenter SQL statements terminated with a";"/*enter the. Table command to view the tables in the database*/SQLite>. Tableandroid_metadata Book/*enter the. Schema command to view the build table statement*/SQLite>. Schemacreate TABLE android_metadata (locale TEXT); CREATE TABLE book (id integer PRIMARY KEY autoincrement, author text, price real, pages integer,name text); sqlite>

This proves that the BOOKSTORE.DB database and Book table have indeed been created successfully.

After you type the. exit or. Quit command, you can exit the editing of the database, and then type the exit command to exit the device console.

View of SQLite database in Android

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.