browse data in Android SQLite Database

后端 未结 8 2108
攒了一身酷
攒了一身酷 2020-12-04 16:42

Is there a way for an Android user to browse the SQLite databases on his/her phone and view the data in the databases?

I use the SoftTrace beta program a lot. It\'s

8条回答
  •  独厮守ぢ
    2020-12-04 17:29

    Actually the most available (yet still hacky) way of getting "live" results from a database while developing on emulator that I found is this:

    1. Create a script to pull the database from emulator, something like this

      #!/bin/bash
      
      ANDROID_HOME=/path/to/sdk
      ADB=$ANDROID_HOME/platform-tools/adb
      REMOTE_DB_PATH=/data/data/com.yourpackage.name/databases/your_db
      LOCAL_DB_PATH=.
      
      while true; do
      
        echo copying DB...
        `$ADB pull $REMOTE_DB_PATH $LOCAL_DB_PATH`
        sleep 3
      
      done
      

      Run it.

    2. Install SQLite Manager plugin for Firefox

    3. Open your local copy of the database (which is constantly overridden by the running script from step 1)

    4. Enter your SQL:

      enter image description here

    5. Select File->Reconnect

    6. Click Run SQL

    The key trick is that reconnecting does not reset SQL entered on step 4 (as it does, for example, in SQLite Browser), so you can repeat steps 5,6 to see "live" results from your android database.

    Note that this only works for emulator, it won't work for a real device (even a rooted one).

提交回复
热议问题