HowTo: Looking for offline database files

Official Content
This documentation is valid for:

Getting your devices offline database files will help you significantly on testing and debugging the synchronization processes of your application.
In this document is explained how to take access to this files wheter using iOS or Android platform, and even if you are using real devices or simulators.

Using iOS Simulator:

Every time you run a new application in the iOS emulator it is going to be created a new folder with a random name in /Users/<your_user>/Library/Application Support/iPhone Simulator/<iOS target version>/Applications/
Next step is to find the folder that contains the application we have recently run:

Looking for offline database files - iOS applications folders

Tip: It could be useful to order folders by Date Modified.
Tip: As from Mac OSX Lion, Library folder is hidden by default, anyway, it is possible to access that folder by using the "Go to folder..." action in the "Go" menu of Finder application. 

 Once you have found that folder, in the Documents folder you will find the .sqlite file you were looking for. It is named as <AppName>.sqlite, where <AppName> is the name of the main object associated with the offline database. If needed, the <AppName>_hashes.json file is in the same folder.

Looking for offline database files - iOS application found

Using iOS Devices:

If you are using your iOS device to test your application, once you have run the application in Xcode, open the Organizer by going to Window/Organizer ( Or press Command+Shift+O )

Find your application selecting the Applications section under your device in the left panel.
Once you have found the application, you can download its content as a Xcode Application Data Package file (.xcappdata)

Looking for offline database files - Xcode organizer

To open that package just right-click on it and select “Show package content”.
After that, a Finder folder will pop up, and finally if you go to the Documents folder you will find the <AppName>.sqlite file you are looking for:

Looking for offline database files - Showing package contents

If needed, the <AppName>_hashes.json file is in the same folder.

Using Android Virtual Devices:

As said in the HowTo: Storing Android offline database files in SD card  document, we can decide whether to choose local storage, or choose the external storage (sdcard) to place the offline database files.

If local storage is selected, then the offline database files will be stored in the AVD at the following directory: /data/data/<Android Package Name>/files/db/
Otherwise it is going to be stored in the following directory: <External Storage>/Android/data/<Android Package Name>/files/db/
Where the <Android Package Name> is the value of the Main object Android Package Name property and <External Storage> is the path to the device external storage disk (it may vary on different devices), for example: "/storage/sdcard/", "/mnt/shell/emulated/sdcard/", among others.

Finally we need to know the name of the offline database files, and this files are named like: <appName>.sqlite where <appName> is the name in lower case of the Main offline object. If needed, the <AppName>_hashes.json file is in the same folder.

Summarizing:

  • If using local storage, the full path will be: /data/data/<Android Package Name>/files/db/<appName>.sqlite
  • Otherwise,  the full path will be: <External Storage>/Android/data/<Android Package Name>/files/db/<appName>.sqlite

Now that we have the full path of the file, we can get that file using the adb push command.

We open the cmd console and navigate towards <AndroidSDKDirectory>/platform-tools
After that, execute the following command:

adb pull <fullDatabaseFilePath> <localPath>

Where <localPath> is the destination where we want the .sqlite file to be placed in your computer.

For example:

adb pull /data/data/com.artech.abcoffline.abcoffinetest/files/db/abcoffinetest.sqlite C:/temp/MyOfflineDatabaseFiles
adb pull /data/data/com.artech.abcoffline.abcoffinetest/files/db/abcoffinetest_hashes.json C:/temp/MyOfflineDatabaseFiles

Using Android Devices:

If offline database files are going to be stored in the SD card, as explained in the HowTo: Storing Android offline database files in SD card document, once you plug as a store device your Android device, go to the following path in the sdcard device: <sdcard path>\Android\data\<Android Package Name>\files\db

Where the <Android Package Name> is the value of the Main object Android Package Name property.
The <appName>.sqlite file will be placed in that folder.

For example:

Computer\GT-P5110\Tablet\Android\data\com.artech.abcoffline.abcoffinetest\files\db\abcoffinetest.sqlite
Computer\GT-P5110\Tablet\Android\data\com.artech.abcoffline.abcoffinetest\files\db\abcoffinetest_hashes.json

Android Considerations

All images referenced by the offline database are visible even if the device is offline, and you can find those images in the files\blobs folders.

How to open the SQLite DB?

Once you copy the SQLite file to your PC you can use any Application to open it like SQLSpy 

 

See also



Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.