Operate the database directly in the ADB shell using the sqlite3 command

Source: Internet
Author: User

 operate the database directly in the ADB shell using the sqlite3 command


In general, mobile phones in the development phase will be the Sqlite3 module into the mirror. For example, in Android 5.1, the path is/system/xbin/sqlite3. (But for ordinary mobile phones, it may not be possible to bring this module, so this article only for the mobile phone development phase debugging)


First check whether the Sqlite3 file exists in the phone, and if it exists, you can use the Sqlite3 command directly under the ADB shell:



example : Changing the settings entry in the system settings database: Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED

(This setting is a new addition to the Android 5.1 system to determine whether the access network to determine the validity of the network connection)

~ Search in the framework source code to know the definition in Base/core/java/android/provider/settings.java captive_portal_detection_ ENABLED = "captive_portal_detection_enabled";

~ Enter the settings provider directory:

Cd/data/data/com.android.providers.settings/databases


Database operation started:

    • Sqlite3 settings.db command to enter the SQLite operator interface, use the. Tables command to view the tables in this database:

    • Select to view the data in the global table:

SELECT * from Global;

    • As you can see, no field names are displayed, and if we don't know their field names, we can use the. Header on to turn on the display field name:

    • After the field name is displayed, the query target record is made:

Sqlite> SELECT * from global where name= ' captive_portal_detection_enabled ';

    • The value is now 1 and is changed with the update command:

sqlite> Update global set value= ' 0 ' where name= ' captive_portal_detection_enabled ';

    • You can see that the changes have been made. The value of the Value field has been changed to 0. Success!

For the framework debug, perhaps this modification can help you in the development of the debugging phase, without modifying the software code to do some tests associated with the system settings (for items that cannot be set in the Settings app).

Of course, the sqlite3 command can be used for all provider applications and for the DB to be added and censored.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Operate the database directly in the ADB shell using the sqlite3 command

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.