android sqlite3使用命令
16lz
2021-01-26
sqlite3可以让我们对机器中的数据库直接进行操作,对于调试机,可以直接通过adb shell进入机器后使用。
开启模拟器,执行adb shell后进入adb 环境就可以用sqlite3这个工具。
myron@myron-laptop:~$ adb shell# sqlite3SQLite version 3.7.4Enter ".help" for instructionsEnter SQL statements terminated with a ";"
sqlite3的命令分为SQL命令和非SQL命令
其中非SQL命令以"."开头,可以通过".help"来查看,通过".quit"退出sqlite3
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#
对于不以"."开头的语句sqlite3都当作SQL语句来执行,SQL语句以分号结束,下面目录中有应用自己的数据库
# pwd/data/data/com.android.providers.settings/databases# lssettings.dbsettings.db-shmsettings.db-wal
sqlite3后接数据库名可以打开已存在的数据库或者新建一个数据库,下面为打开目录中的settings.db
# sqlite3 settings.dbSQLite version 3.7.4Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite>
sqlite> .tablesandroid_metadata bookmarks system bluetooth_devices secure
通过select 语句可以查看表的内容
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
如果第一行的header不显示,可以通过如下命令让其显示
sqlite> .header onsqlite>
更多相关文章
- Android(安卓)开发之SQLite基础
- Android(安卓)Studio将本地计算机文件上传到模拟器scard文件中
- Android数据库安全permission
- Gradle命令为Unity导出Jar备忘
- 关于android通过servlet访问MySql数据库的问题(附带简单的JSON使
- 下载 编译 Android源代码 和 Android(安卓)kernel源代码
- Android(安卓)adb启动任意app的几种方式
- Flutter混编问题汇总实践
- 模拟器中使用Market