sqlite3
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以使用 sqlite3
指令列程式,透過遠端殼層管理裝置,或是透過主體機器進行管理
由 Android 應用程式建立的 SQLite 資料庫。sqlite3
工具包含許多
例如 .dump
來顯示資料表的內容
.schema
來列印現有資料表的 SQL CREATE 陳述式。這項工具還提供
可讓您即時執行 SQLite 指令
請參閱 SQLite 說明文件
說明文件。如需其他說明文件,請造訪
sqlite3
和
支援 SQL 語言規格
由 SQLite 提供
如何透過遠端殼層使用 sqlite3
:
- 輸入下列指令,進入遠端殼層:
adb [-d|-e|-s {<serialNumber>}] shell
- 在遠端殼層中輸入下列指令,啟動
sqlite3
工具:
sqlite3
您也可以選擇指定您要探索的資料庫完整路徑。模擬器/裝置執行個體會將 SQLite 資料庫儲存在目錄中
/data/data/<package_name>/databases/
。
- 叫用
sqlite3
後,即可發出
指令中的指令如要離開並返回 ADB 遠端殼層,請輸入
exit
或按下 Control + D 鍵。
例如:
$ adb -s emulator-5554 shell
# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
SQLite version 3.3.12
Enter ".help" for instructions
.... enter commands, then quit...
# sqlite> .exit
注意:你必須具備檔案系統的根層級存取權,才能查看檔案
位於 /data/data
目錄階層中
如要在裝置本機使用 sqlite3
(而非殼層內),請從裝置提取資料庫檔案,然後啟動 sqlite3
:
- 將裝置上的資料庫檔案複製到主機電腦:
adb pull <database-file-on-device>
- 啟動
sqlite3
工具,並指定資料庫檔案:
sqlite3 <database-file-on-host>
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# sqlite3\n\nFrom a remote shell to your device or from your host machine, use the [`sqlite3`](https://www.sqlite.org/) command-line program to manage\nSQLite databases created by Android applications. The `sqlite3` tool includes many\nuseful commands, such as `.dump` to print out the contents of a table and\n`.schema` to print the SQL CREATE statement for an existing table. The tool also gives\nyou the ability to execute SQLite commands on the fly.\n\nRefer to the [SQLite\ndocumentation](https://sqlite.org/docs.html) for full details. For additional documentation, visit\n[`sqlite3`](https://sqlite.org/cli.html) and the\n[SQL language specification](https://sqlite.org/lang.html) supported\nby SQLite.\n\nTo use `sqlite3` from a remote shell:\n\n1. Enter a remote shell by entering the following command: \n\n ```\n adb [-d|-e|-s {\u003cserialNumber\u003e}] shell\n ```\n2. From the remote shell, start the `sqlite3` tool by entering the following command: \n\n ```\n sqlite3\n ```\n\n You can also optionally specify a full path to a database that you want to explore.\n Emulator/device instances store SQLite databases in the directory\n `/data/data/\u003cpackage_name\u003e/databases/`.\n3. Once you invoke `sqlite3`, you can issue commands in the shell. To exit and return to the adb remote shell, enter `exit` or press Control+D.\n\nFor example: \n\n```\n$ adb -s emulator-5554 shell\n# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db\nSQLite version 3.3.12\nEnter \".help\" for instructions\n.... enter commands, then quit...\n# sqlite\u003e .exit\n```\n\n**Note:** You need root access to the file system to view files\nwithin the `/data/data` directory hierarchy.\n\nTo use `sqlite3` locally, instead of within a shell,\npull the database file from the device and start `sqlite3`:\n\n1. Copy a database file from your device to your host machine: \n\n ```\n adb pull \u003cdatabase-file-on-device\u003e\n ```\n2. Start the `sqlite3` tool, specifying the database file: \n\n ```\n sqlite3 \u003cdatabase-file-on-host\u003e\n ```"]]