Your app may need data to be loaded onto your device rather that getting it from a service at the time it is needed. Taking your data offline allows you to access it without a network connection. The needed data may have been authored using ArcGIS for Desktop, and also may include data from other sources. There are three common workflows that you can use to deploy data that your app can use offline. This topic describes these workflows.
Sideloading means to use a tool to copy your data to a known location on your device before using your app, and then use the ArcGIS QML Extras plug-in to determine at run time where that location is.
To sideload data to your device, follow these steps:
- Author your tile packages, geodatabases, offline locators, offline network datasets, or mobile map packages in ArcGIS for Desktop.
- Using a file explorer tool (for example, ADB/Android File Transfer for Android, iTunes for iOS, and the native file explorers for each desktop platform), copy the data to the specified data location.
- When you reference these files in QML code, use the ArcGIS Extras plug-in to refer to a location where the data will be stored relative to where your app resides on the device.
- Android location is /sdcard/ArcGIS/Runtime/Data.
- iOS location is <your_app>/Documents/ArcGIS/Runtime/Data.
- Mac location is ~/ArcGIS/Runtime/Data.
- Windows location is %userprofile%\ArcGIS\Runtime\Data.
- Linux location is $HOME/ArcGIS/Runtime/Data.
Each operating system has a similar but slightly different data location:
By storing data in these locations and using the System.userHomeFolder function, you can be sure that your app will be able to read and write data on any deployed operating system.
When deploying to iOS, you must modify the .plist file for the template provided with the SDK to enable file sharing with your app. Modify the .plist file to change UIFileSharingEnabled from FALSE to TRUE. To use this functionality, plug in your device, open iTunes and in it open your device, click Apps, and scroll down to the bottom. Find your app, and use the Add dialog box to add your data. If you are using folders, make sure to create a clone of the structure you want, and add the topmost folder. This will copy everything to your app's Documents folder.
Bundle data as a Qt resource
Although Qt supports reading from embedded resources, ArcGIS Runtime uses standard C file I/O which does not support Qt resources. Therefore when you bundle your data with your app for deployment, you must copy the data from the Qt resource file (.qrc file) to a working data location on the device before you can use it. The ArcGIS QML Extras plug-in contains a copyFile function that copies files from the .qrc file to a working data location.
This workflow is good for smaller data files such as small geodatabases or tile packages. For performance and app size reasons, this workflow is not recommended for large data files.
Download data at run time
You can host your data on ArcGIS Online or Portal for ArcGIS, and use the API to download the data as a portal item, storing it in a working data location. Use the ArcGIS Extras plug-in to refer to the working data location relative to where your app resides on the device. After downloading ands storing the data locally, your app can access the data without a network connection.