Android View and manage SQLite database

Source: Internet
Author: User
Tags sqlite database sqlite manager

You can use the Eclipse plugin Ddms to view it in Android, or you can use the ADB tool in the Android Toolkit. The SQLite database in the Android project is located in the/data/data/ project package /databases.

Use DDMS to export the SQLite database.

1, first open the Android Project debug mode, and then find the display DDMS:

Select Ddms

2. Switch to DDMS, Show File Explorer window, find/data/data/

Then find the Package folder, open databases, you can see the SQLite database files. Choose to export it.

This will be the SQLite database file exported to file, and then use the SQLite interface management tools such as SQLite Administrator, SQLite man or the Firefox plugin SQLite manager, etc. open it.

Accessing the SQLite database using the ADB tool

Android Debug Bridge (ADB) is a generic debugging tool for Android, it can update the code in the device or emulator, can manage the predetermined port, can run the shell command on the device, we know that Android is based on the Linux kernel, Its internal file structure is also organized using a Linux file, so accessing its file structure requires the use of a shell. This time we will use the shell to access the SQLite database files in the Android app.

1, run the cmd, switch to the ANDROID-SDK directory, run Adb.exe, plus the parameter shell, the presence of the # sign into the shell command mode, note that ADB to run the Android emulator to enter the shell:

2, the shell command remembers two basic commands LS and CD, similar to the Windows command prompt line dir and CD, represents the list of files in the current directory and enter into the specified directory. After you understand these two commands, you can find the data/data/ Project package name /databases:

Locate the database file:

The next step is to use the SQLite management tool. Type the sqlite3 database name to enter the SQLite management mode.

In the Android SDK comes with Sqlite3.exe, this is the official SQLite management tool, it is a command-line tool. For ease of use, its path is registered to the system environment variable path, the%android_home% is added in path, so only the sample run Sqlite3, you can directly open the SQLite management tool.

SQLite Management Database Chapter

The SQLite command-line tool defaults to; So if it's just a line statement, add it at the end, or type in the next line, so the SQLite command will be executed.

SQLite Common commands:

. tables--view a list of tables for a database

. exit--exiting the SQLite command line

Other commands can be used at any time. Help view assistance. SQL commands can be executed directly on this command line:

Android View and manage SQLite database

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.