Skip to content

Instantly share code, notes, and snippets.

@ktweeden
Last active April 8, 2018 19:38
Show Gist options
  • Save ktweeden/a2ef1c968a11f91e47e38c74b671bef3 to your computer and use it in GitHub Desktop.
Save ktweeden/a2ef1c968a11f91e47e38c74b671bef3 to your computer and use it in GitHub Desktop.

Connecting to a SQLite database on an Android emulator

To access your database via the terminal, make sure that your emulator is running before doing the following:

  1. Get a list of your emulators by typing: ~/Library/Android/Sdk/platform-tools/adb devices

  2. Connect to the emulator you're running your app on: ~/Library/Android/Sdk/platform-tools/adb -s emulator-**** shell

(replace the **** with the correct number for your device, which you will have seen after running the previous command) You are now navigating the file structure of your emulator.

  1. Type the following command to gain root access to the emulator: su

  2. Navigate to the folder containing your db file: cd data/data/yourappsname/databases Your app's name will be somethign like com.example.name.app

  3. Run sqlite3 to connect to your db: sqlite3 yourdatabasename

Ta Da! You can now type normal SQL queries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment