Hello.

Engaged in the development of an android. I use SQLite database. In the development process, it would be convenient to "merge" the database file and look at what lies there with the help of third-party tools.

When I had custom firmware on my phone, I could do it without problems. As far as I remember, I had access to the data folder which contains all the application files.

Now I have a native firmware and no access.

Which exit? Is it possible to get access to the application database file without any extra shamanism? at least for the duration of the development.

    6 answers 6

    There are 3 ways:

    1. Starting with the 14th version of Intellij IDEA, you can access the SQLite database of a device (real or emulator). Access is given via DataSource - something like a JDBC driver, that is, you can watch, make requests, and so on. - but it’s impossible to touch the file itself with your hands. Read here. Works only for the paid version Intellij IDEA (Ultimate version).
    2. You can stupidly get root on your device, then you get access to the directory / data
    3. You can install the command console on the SQLite3 + device itself (all this can be found on the Google Play Market) and through the command line in the device itself (again, you need root).
    • I remember well that on IDEA Ultimate 13, and most likely on 12, too, Database Support plugin was already there. - pavlofff
    • He was always, but did not support a connection to SQLite on an Android device - Barmaley
    • understandably. Everything rests on the root. Thank you for your reply! - Konstantin Pl
    • If the first option, then it works without root - Barmaley

    In IntelliJ IDEA Ultimate there is a Database Support plugin that allows you to fully access the device's database during development: view tables, change content, delete and add records, and so on. - A full database editor connected directly to the database of the developed application. It is unrealistically convenient.

    In free IDE, that for Eclipse, that for Android Studio / IDEA Community there is nothing like this. Google promised in the hazy perspective for AS to make such a plugin, but the dates are pushed somewhere beyond the horizon.

    To all three free IDEs you can connect the SQLiteManager plugin ( about connecting to AS / IDEA ). This is certainly a miserable misunderstanding compared to the ultimat database support, but allows you to view the database on the device.

    You can also pull out your database through the Orthodox adb.

      You need to install the http://facebook.imtqy.com/stetho/ library into the project and use the Chrome DevTools browser. In his arsenal, a lot of extra buns. (View network traffic, View Hierarchy, Database Inspection)

        In Eclipse and Android Studio there is a DDMS File Explorer, through which you can unload the database from the emulator, (from the real one without root you probably can't). So exit using emulator.

        • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky

        As already mentioned here, you can extract the database file from the device. But if the device is real, you need to be able to get into the application directory, because the directory is accessible only to the application itself.

        For this there is a run-as command, which allows you to execute commands with the rights of a specific application. In the example below, com.yourpackge.name is the application id, filename.db is the name of the file with the base.

         adb -d shell "run-as com.yourpackge.name ls /data/data/com.yourpackge.name/databases/” adb -d shell "run-as com.yourpackge.name cat /data/data/com.yourpackge.name/databases/filename.db > /sdcard/filename.sqlite" adb pull /sdcard/filename.sqlite 

        Alternatively, using an additional library .