Using SQLite


  1. Start Running the Android Database Application.
  2. In order to access the SQLite database from the command line shell, the application has to be active.

  3. Activate a Command Prompt.
  4. Pick the following Windows options:
       Start ⇒ All Programs ⇒ Accessories ⇒ Command Prompt
  5. Enter the Directory platform-tools.
  6. For my computer, the directory is located at
       C:\> cd C:\Android\SDK\platform-tools\
    To find where your Android SDK is located, pick the following Android Studio options:
       Tools ⇒ SDK Manager
    The location can be found on the top of the screen.

  7. Start a Remote Shell.
  8. Enter the command “adb shell” where adb is Android Debug Bridge, a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device.


  9. Enter the Database.
  10. Enter the command:
       # sqlite3 /data/data/yourpackage/databases/yourdbname
    For my computer, the command is as follows:
       # sqlite3 /data/data/com.example.wenchen.sqlitedemo/databases/applicationdata;
    where
    • yourpackage: My package is named com.example.wenchen.sqlitedemo and
    • yourdbname: My database is named applicationdata.


    If you encounter a problem of
    Error: unable to open database "applicationdata": unable to open database file
    check the Stackoverflow to solve it by adding two commands:
     shell> adb root
     shell> adb root restarting adbd as root
     shell> adb shell
  11. Start Managing the Database.
  12. Check the Command Line Shell for SQLite.


  13. Exit the Database and adb.
  14. Enter the commands:
       sqlite> .exit 
       .exit
       # exit 
       exit
       C:\Android\SDK\platform-tools>