Android Sqlite basic commands

Source: Internet
Author: User

To view the database, you must first find the db file. If you copy the file to a computer, you can view it in many ways. on your mobile phone, you can use commands to view it directly and conveniently.

First, you need to find the database location. Generally, the database is stored in the private directory of the program, so you need to obtain the root permission.

Make sure that the development tool is connected to the mobile phone. Open the command line and enter adb shell.

At this time, the root permission is not obtained. Enter su and a prompt will be displayed on the mobile phone to allow the root permission to be obtained.

The suffix is changed to "#" and the root permission is obtained successfully. Then, you can enter the private directory of the application,

Enter cd data/package name/databases/to enter the database directory.

Below are some basic sqlite commands

First open the databaseInput sqlite3 test_db to open a data file named test_db.

To view the database structure,Input. schema

View All data

It seems a little difficult to see,To make the data look more beautiful, enter. head on to display the column name, enter. mode column, and display by class

 

It looks much more comfortable.

To view the number of tables, enter. table

View the structure of a single table. schema TableName

The above command should be enough to simply view the database.

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.