Android sqlite3 command

Source: Internet
Author: User

Sqlite3 allows us to directly operate the database on the machine. for debugging machines, we can directly use ADB shell to enter the machine and use it.

Enable the simulator. Run the ADB shell and enter the ADB environment. You can use the sqlite3 tool.

myron@myron-laptop:~$ adb shell# sqlite3SQLite version 3.7.4Enter ".help" for instructionsEnter SQL statements terminated with a ";"

Sqlite3 Commands include SQL commands and non-SQL commands.

The non-SQL command starts with ".". You can view it through ". Help" and exit sqlite3 through ". Quit ".

sqlite> .help.backup ?DB? FILE      Backup DB (default "main") to FILE.bail ON|OFF           Stop after hitting an error.  Default OFF.databases             List names and files of attached databases.dump ?TABLE? ...      Dump the database in an SQL text format                         If TABLE specified, only dump tables matching                         LIKE pattern TABLE..echo ON|OFF           Turn command echo on or off.exit                  Exit this program.explain ?ON|OFF?      Turn output mode suitable for EXPLAIN on or off.                         With no args, it turns EXPLAIN on..header(s) ON|OFF      Turn display of headers on or off.help                  Show this message.import FILE TABLE     Import data from FILE into TABLE.indices ?TABLE?       Show names of all indices                         If TABLE specified, only show indices for tables                         matching LIKE pattern TABLE..load FILE ?ENTRY?     Load an extension library.log FILE|off          Turn logging on or off.  FILE can be stderr/stdout.mode MODE ?TABLE?     Set output mode where MODE is one of:                         csv      Comma-separated values                         column   Left-aligned columns.  (See .width)                         html     HTML <table> code                         insert   SQL insert statements for TABLE                         line     One value per line                         list     Values delimited by .separator string                         tabs     Tab-separated values                         tcl      TCL list elements.nullvalue STRING      Print STRING in place of NULL values.output FILENAME       Send output to FILENAME.output stdout         Send output to the screen.prompt MAIN CONTINUE  Replace the standard prompts.quit                  Exit this program.read FILENAME         Execute SQL in FILENAME.restore ?DB? FILE     Restore content of DB (default "main") from FILE.schema ?TABLE?        Show the CREATE statements                         If TABLE specified, only show tables matching                         LIKE pattern TABLE..separator STRING      Change separator used by output mode and .import.show                  Show the current values for various settings.stats ON|OFF          Turn stats on or off.tables ?TABLE?        List names of tables                         If TABLE specified, only list tables matching                         LIKE pattern TABLE..timeout MS            Try opening locked tables for MS milliseconds.width NUM1 NUM2 ...   Set column widths for "column" mode.timer ON|OFF          Turn the CPU timer measurement on or offsqlite> .quit# 

For statements not starting with ".", sqlite3 is executed as an SQL statement, and the SQL statement ends with a semicolon. The following directory contains the application database.

# pwd/data/data/com.android.providers.settings/databases# lssettings.dbsettings.db-shmsettings.db-wal

After sqlite3 is connected to the database name, you can open an existing database or create a new database. below is the settings. DB in the Open Directory.

# sqlite3 settings.dbSQLite version 3.7.4Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite> 

Sqlite3 provides multiple commands to view the schema of the Database. ". Tables" allows you to view all the tables of the current database.

sqlite> .tablesandroid_metadata   bookmarks          system           bluetooth_devices  secure 

You can use the SELECT statement to view the table content.

sqlite> select * from secure;_id|name|value1|bluetooth_on|02|data_roaming|04|location_providers_allowed|gps5|assisted_gps_enabled|16|network_preference|17|usb_mass_storage_enabled|18|wifi_on|09|wifi_networks_available_notification_on|110|preferred_network_mode|011|cdma_cell_broadcast_sms|112|preferred_cdma_subscription|113|mock_location|114|backup_enabled|115|backup_transport|android/com.android.internal.backup.LocalTransport16|mount_play_not_snd|117|mount_ums_autostart|018|mount_ums_prompt|119|mount_ums_notify_enabled|120|accessibility_script_injection|021|accessibility_web_content_key_bindings|0x13=0x01000100; 0x14=0x01010100; 0x15=0x02000001; 0x16=0x02010001; 0x200000013=0x02000601; 0x200000014=0x02010601; 0x200000015=0x03020101; 0x200000016=0x03010201; 0x200000023=0x02000301; 0x200000024=0x02010301; 0x200000037=0x03070201; 0x200000038=0x03000701:0x03010701:0x03020701;22|long_press_timeout|50023|touch_exploration_enabled|024|android_id|702662e68643232c27|enabled_input_methods|com.android.inputmethod.pinyin/.PinyinIME:jp.co.omronsoft.openwnn/.OpenWnnJAJP:com.android.inputmethod.latin/.LatinIME28|input_methods_subtype_history|29|selected_input_method_subtype|-130|default_input_method|com.android.inputmethod.latin/.LatinIME31|selected_spell_checker|com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService32|selected_spell_checker_subtype|033|throttle_reset_day|1034|device_provisioned|135|install_non_market_apps|136|backup_provisioned|137|wifi_country_code|us

If the header of the first line is not displayed, run the following command to display the header:

sqlite> .header onsqlite> 

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.