I am using Android Studio on a Mac, everything on the latest version. Say I do this:
SQLiteDatabase db;
db = yourAppContext.openOrCreateDatabase("db.sqlite3", Context.MODE_PRIVATE, null);
Thanks to this link:
http://www.c-sharpcorner.com/UploadFile/e14021/know-where-database-is-stored-in-android-studio/
it's possible to exactly find the directory holding your actual SQLite3 database on the emulator as it runs:
Great stuff.
Next you can click the Pull button, and pull that file to say your desktop on the Mac. Awesome.
But, how do you actually find literally that folder ("databases" in the example), on your Mac?
i.e., using a normal shell terminal, I want to "cd" to there.
Where is that folder, in the ordinary 'nix file structure of the host Mac computer?
SQLite is included in macOS and Mac OS X by default. It is located in the /usr/bin directory and called sqlite3. Using SQLite, users can create file-based databases that can be transported across machines, platforms, etc.
If you are using Linux or a Mac, open a terminal window instead a command prompt. Open a command prompt (cmd.exe) and 'cd' to the folder location of the SQL_SAFI. sqlite database file. run the command 'sqlite3' This should open the SQLite shell and present a screen similar to that below.
adb
(Android Debug Bridge) is needed to access an emulator device's filesystem via the command-line . If you don't already have it installed you can download it here.
Once installed it's just a matter of using a few commands to view/access the files:
- Open
Terminal.app
.- Execute
adb devices
(this should list your current emulator devices).- Connect to the emulator device with
adb shell
.- Change directory
cd
to the folder where your app databases are.- Type
ls
to see which database files are present.
In Terminal it would look something like this:
List the emulator devices:
$ adb devices
List of devices attached
emulator-5554 device
Connect to device with adb shell
:
$ adb -s emulator-5554 shell
Change directory (cd
) into it's SQLite3
database location (package name is usually com...
):
adb shell
$ cd /data/data/<your app package name>/databases/
List the files in the databases
directory:
adb shell
$ ls
db.sqlite3
That's really the basics of it! It's also possible to push/pull
to copy files from the emulator (remote) to your (local) filesystem:
adb pull /data/data/com.yourpackagename.app/databases/db.sqlite3 /local/save/path
If Permission is denied run ADB in root mode:
adb root
More information:
or you can pull databases using this command
adb pull /data/data/com.application/databases/ for example adb pull /data/data/com.zameen.propforce/databases/
secondly that folder is not accessible unless your device is rooted or you are using emulator
if your device is rooted. you get super user access by adb su command then you can go to this directory
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