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