Inspecting android sql database from Eclipse

前端 未结 4 1058
眼角桃花
眼角桃花 2020-12-11 15:51

Is there a way to directly inspect an SQLite3 database in Android via Eclipse or do I have to do this via the shell?

4条回答
  •  爱一瞬间的悲伤
    2020-12-11 16:18

    Unfortunately AFAIK you always have to use the shell currently. (Well, not quite. You can use DDMS in Eclipse to pull the database, but that's not much better than using the shell).

    Basically you can either 1) pull the database file from the emulator / phone and then inspect it, or you can 2) manually run some SQL queries from inside the emulator/phone.

    For 1, I would recommend creating a script. Here is simple example

    $ cat android_pull_db 
    #!sh
    adb shell "chmod 777 /data/data/com.mypackage/databases/store.db"
    adb pull /data/data/com.mypackage/databases/store.db 
    $ 
    

    To create your own, paste the lines from #!... down to adb pull ... into a text file, and save it somewhere. Modify the package location and database filename. Make it executable, and add it to your path.

    For 2, just execute this:

    $ adb shell
    $ cd /data/data/com.yourpackage/databases
    $ sqlite3 your-db-file.db
    > .help
    

提交回复
热议问题