blob: 71e614fa37fffbaaab08b0df032fd5545141ac53 [file] [log] [blame]
Robert Ly6ffacae2010-12-16 17:50:43 -08001page.title=sqlite3
2@jd:body
3
4 <p>From a remote shell to your device or from your host machine, you can use the <a href=
5 "http://www.sqlite.org/sqlite.html">sqlite3</a> command-line program to manage SQLite databases
6 created by Android applications. The <code>sqlite3</code> tool includes many useful commands,
7 such as <code>.dump</code> to print out the contents of a table and <code>.schema</code> to print
8 the SQL CREATE statement for an existing table. The tool also gives you the ability to execute
9 SQLite commands on the fly.</p>
10
11 <p>To use <code>sqlite3</code> from a remote shell:</p>
12
13 <ol>
14 <li>Enter a remote shell by entering the following command:
15 <pre>adb [-d|-e|-s {&lt;serialNumber&gt;}] shell</pre>
16 </li>
17
18 <li>From a remote shell, start the <code>sqlite3</code> tool by entering the following command:
19 <pre>sqlite3</pre>
20
21 <p>You can also optionally specify a full path to a database that you want to explore.
22 Emulator/device instances store SQLite3 databases in the directory
23 <code>/data/data/&lt;package_name&gt;/databases/</code>.</p>
24 </li>
25
26 <li>Once you invoke <code>sqlite3</code>, you can issue <code>sqlite3</code> commands in the
27 shell. To exit and return to the adb remote shell, enter <code>exit</code> or press
28 <code>CTRL+D</code>.</li>
29 </ol>
30
31
32 <p>Here's an example:</p>
33 <pre>$ adb -s emulator-5554 shell
34# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
35SQLite version 3.3.12
36Enter ".help" for instructions
37<em>.... enter commands, then quit...</em>
38# sqlite&gt; .exit
39</pre>
40
41 <p>To use <code>sqlite3</code> locally, instead of within a shell,
42 pull the database file from the device and start {@code sqlite3}:</p>
43
44 <ol>
45 <li>Copy a database file from your device to your host machine:
46 <pre>
47adb pull &lt;database-file-on-device&gt;
48</pre>
49 </li>
50
51 <li>Start the sqlite3 tool from the <code>/tools</code> directory, specifying the database
52 file:
53 <pre>
54sqlite3 &lt;database-file-on-host&gt;
55</pre>
56 </li>
57 </ol>