SQLlite3
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
จาก Shell ระยะไกลไปยังอุปกรณ์หรือจากเครื่องโฮสต์ ให้ใช้โปรแกรมบรรทัดคำสั่ง sqlite3
เพื่อจัดการ
ฐานข้อมูล SQLite ที่สร้างโดยแอปพลิเคชัน Android เครื่องมือ sqlite3
มีหลายประเภท
คำสั่งที่เป็นประโยชน์ เช่น .dump
เพื่อพิมพ์เนื้อหาของตารางและ
.schema
เพื่อพิมพ์คำสั่ง SQL CREATE สำหรับตารางที่มีอยู่ เครื่องมือยังให้
คุณสามารถเรียกใช้คำสั่ง SQLite ได้ทันที
โปรดดู SQLite
เพื่อดูรายละเอียดทั้งหมด ดูเอกสารเพิ่มเติมได้ที่
sqlite3
และ
รองรับข้อกำหนดภาษา SQL
โดย SQLite
วิธีใช้ sqlite3
จาก Shell ระยะไกล ให้ทำดังนี้
- ป้อน Remote Shell โดยป้อนคำสั่งต่อไปนี้
adb [-d|-e|-s {<serialNumber>}] shell
- จาก Remote Shell ให้เริ่มเครื่องมือ
sqlite3
โดยป้อนคำสั่งต่อไปนี้
sqlite3
นอกจากนี้ คุณยังเลือกระบุเส้นทางแบบเต็มไปยังฐานข้อมูลที่ต้องการสำรวจได้ด้วย
อินสแตนซ์โปรแกรมจำลอง/อุปกรณ์จัดเก็บฐานข้อมูล SQLite ในไดเรกทอรี
/data/data/<package_name>/databases/
- เมื่อเรียกใช้
sqlite3
คุณจะออก
ใน Shell ได้ หากต้องการออกและกลับไปยัง Shell ระยะไกล 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
ภายในเครื่อง แทนที่จะใช้ภายใน Shell
ดึงไฟล์ฐานข้อมูลจากอุปกรณ์และเริ่ม sqlite3
- คัดลอกไฟล์ฐานข้อมูลจากอุปกรณ์ไปยังเครื่องที่โฮสต์
adb pull <database-file-on-device>
- เปิดเครื่องมือ
sqlite3
โดยระบุไฟล์ฐานข้อมูล ดังนี้
sqlite3 <database-file-on-host>
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[null,null,["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],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 ```"]]