How do I pull the sqlite database from the android device like emulator?
The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.
You can use the SQLite . clone dot command to create a clone of the current database. The way it works is quite simple. You simply use .
We can retrieve anything from database using an object of the Cursor class. We will call a method of this class called rawQuery and it will return a resultset with the cursor pointing to the table. We can move the cursor forward and retrieve the data.
You can use these commands for pulling the data base from your device. Typing these commands through android studio is very easy. Please make sure you have set the path of adb globally to your system. Then open the "terminal" window from bottom to android studio and near to "Android Monitor". Now you just update the following commands with actual package name of your app and database file name. You will get your file out from the device.
adb shell "run-as package.name chmod 666 /data/data/package.name/databases/file" adb pull /data/data/package.name/databases/file . adb shell "run-as package.name chmod 600 /data/data/package.name/databases/file"
the command for Android 5.0+ /data/data/package.name/databases/file would be:
adb shell "run-as package.name chmod 666 /data/data/package.name/databases/file" adb exec-out run-as package.name cat databases/file > newOutFileName adb shell "run-as package.name chmod 600 /data/data/package.name/databases/file"
You can use Android Device Monitor to pull it. Go to Tools -> Android -> Android Device Monitor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With