How to check sqlite database tables on device?

I developed an application that creates several tables, but I want to check these tables. I know that there is a way to use the sqlite3 adb shell command, but this does not work for devices ... It works fine with the emulator. I use the device because it is faster than the emulator for testing. So my question is: is there a way to check the database table created on the device using any eclipse plugin or any sqlite database manager?

+4
source share
5 answers

There are sqlite applications on an exchange platform (Windows, Mac OS X, etc.).

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

0
source

if you are embedded, you can extract your database file from data / data / com.yourapp.title / databases and then view it in the SQL database manager, for example: SQLite Database Browser

If you are not embedded, you cannot view the internals of the database, but perhaps you have a cursor adapter associated with a list that displays the contents of the database table or something like that.

+1
source
  • create the application in debug mode.
  • in the shell write run-as your.package.name . this will switch to the UID of your application (by gaining access to the application data folder).
  • cat /data/data/your.package.name/databases/database_name > /sdcard/database_name . This copies your database file to the SD card.

Now you can freely view your database on your SD card.

+1
source

Many devices do not have external memory support, instead they have large internal memory, but this will not cause problems with writing data using an external memory code, since these devices have a different privacy policy related to access to internal data or mobile data. You may need to use the File Explorer application to view files on such devices without external memory support. Using the file explorer application, you can see the application directory or the file that you created for your application.

0
source

I figured out an easy way to debug my database without using or copying the database. I just installed the simple and free SQlite manager on my device, and I added the static final lines to the SQLLiteOpenHelper class:

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

Then I install the private constructor as follows:

 //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); } 

Thus, your SQlite manager will find your database during debugging, because it will be located in your sd, and you can see it without problems and without rooting.

0
source

Source: https://habr.com/ru/post/1443862/


All Articles