browse data in Android SQLite Database

后端 未结 8 2050
攒了一身酷
攒了一身酷 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:10

    The Questoid plugin appears to cost $9 and requires registering. Another alternative on Windows is to download the open-source public-domain SQLLite Browser (link below) and then pull the database from the phone. In Eclipse you can do this from the File Browser, going to the /data/data/[packagename]/databases directory on the phone or emulator, and clicking "Pull a File From The Device" in the top right. Save the database locally, then open with the SQLite Browser.

    http://sourceforge.net/projects/sqlitedbrowser/

    0 讨论(0)
  • 2020-12-04 17:15

    You can view you database from your app using this library . https://github.com/sanathp/DatabaseManager_For_Android

    With this library you can manage your app SQLite database from you app itself. you can view the tables in your app database , update ,delete, insert rows to your tables

    Its a single java activity file ,just add the java file to your source folder.When the development is done remove the java file from your src folder thats it .

    It helped me a lot .Hope it helps you too .

    You can view the 1 minute demo here : http://youtu.be/P5vpaGoBlBY

    0 讨论(0)
  • 2020-12-04 17:19

    If you were lucky enough to get IntelliJ Ultimate then you can plug the device in, open 'Database' tab on the right, click +, select SQLite. The rest is trivial.

    One thing to keep in mind with it is that you have to keep clicking "Synchronize" button on the database (or on selected table) to see the changes made externally, which is very annoying.

    0 讨论(0)
  • 2020-12-04 17:20

    The database for a specific app lives in /data/data/[packagename]/databases

    The packagename is the package you define in your manifest, for instance /data/data/org.vimtips.supacount/databases/counts.db.

    You can view it with adb shell and type sqlite3 /data/data/org.vimtips.supacount/databases/counts.db

    Or you can pull it from the device to look at it with a third party utility, with a command like adb pull /data/data/org.vimtips.supacount/databases/counts.db ..

    This assumes you have permission to view the database, which you might not have if you didn't write the app yourself... but in that case, is it actually a programming question?

    0 讨论(0)
  • 2020-12-04 17:25

    See this answer. You can use Stetho library from Facebook and then just browser you database from Chrome :)

    0 讨论(0)
  • 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).

    0 讨论(0)
提交回复
热议问题