4

I have developed App which creates multiple tables , but I want to check those tables. I know there is a way using adb shell sqlite3 command but that doesn't work for devices... It works fine with emulator. I am using device because its faster than emulator for testing. So my question is, is there any way to check the database table that is created in device using any eclipse plugin or any sqlite database manager?

4

5 回答 5

1

if you're rooted, you can pull your database file out of data/data/com.yourapp.title/databases and then view it in an sqlite database manager such as: SQLite Database Browser

if you're not rooted, you can't view the innards of the database but perhaps you can have a cursor adapter linked to a listview that will show the contents of a database table or something of the sort.

于 2012-11-03T19:56:26.247 回答
1
  1. build your application in debug mode.
  2. in the shell, write run-as your.package.name. by this your are switchin to the UID of your app (gaining access to your application data folder).
  3. cat /data/data/your.package.name/databases/database_name > /sdcard/database_name. this copies your database file to the sdcard.

you can now browse your database freely on your sdcard.

于 2012-11-04T09:37:57.210 回答
0

There are sqlite applications over difference platform (Windows, Mac OS X, etc).

I think it a good idea to adb pull the db file to your computer and use your favorite sqlite application to check the db file.

于 2012-11-04T09:42:32.327 回答
0

many devices don't have external memory support instead they have big internal memory, but it will not cause any problem writing data using external memory code as these devices have different privacy policy related to access to internal data or mobile data. You might have to use file explorer app to view the files in such devices with no external memory support. With the help of file explorer app, you will be able to see the application directory or file whichever you have created for your app.

于 2014-05-08T15:21:42.713 回答
0

I figured out a simple way to debug my database without rooting or copying the database. I just installed a simple and free SQlite manager in my device and I added to static final strings into my SQLLiteOpenHelper class:

private static final String DATABASE_NAME = "myDatabaseName.db";
private static final String DATABASE_NAME_DEBUG_PATH = "/mnt/sdcard/";

Then, I set the private constructor like this:

//Defaut constructor.
    private DatabaseHelper(Context context) {
        //Allow database access without rooting the device.
        super(context, (BuildConfig.BUILD_TYPE == "debug") ? DATABASE_NAME_DEBUG_PATH + DATABASE_NAME : DATABASE_NAME, null, DB_VERSION);
    }

This way your SQlite manager will find your database while you debug because it will be located in your sd and you will be able to see it with no problems and no rooting.

于 2015-10-29T16:28:35.117 回答