Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pull the sqlite database from the android device? [duplicate]

Tags:

How do I pull the sqlite database from the android device like emulator?

like image 237
Manikandan Palanisamy Avatar asked Jul 22 '12 06:07

Manikandan Palanisamy


People also ask

Where is my SQLite database stored android?

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.

Can I copy SQLite database?

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 .

Which method is used to retrieve data from SQLite of Android?

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.


2 Answers

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" 
like image 64
Manmohan Soni Avatar answered Sep 20 '22 14:09

Manmohan Soni


You can use Android Device Monitor to pull it. Go to Tools -> Android -> Android Device Monitor

  1. Select your device from the left list.
  2. Select FileExplorer tab
  3. Expand data-> data -> "yourpackageName" -> databases
  4. Select your databaseFile and on the top right click on this icon save icon pull a file form a device.
  5. Save it on your desk then use this tool to open it: http://sqlitebrowser.org/
like image 26
Moaz Rashad Avatar answered Sep 20 '22 14:09

Moaz Rashad