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 Desktop and may include data from other sources. Three common workflows to deploy data your app can use offline are described in this topic.
Copy data to the device (sideload data)
To copy your data to the device, also known as sideloading, you use a tool to copy the data to a known location on the device before the app is used, and then you use the ArcGIS QML Extras plug-in to determine at run time where that location is.
To copy data to a device:
- Author your tile packages, geodatabases, offline locators, offline network datasets, or mobile map packages in ArcGIS 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 SDK 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 ArcGIS Enterprise, 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.
Additional data resources
Depending on your app's needs, you may need some additional data resources.
Projection engine files
If your app is using grid-based transformations, deploy the required Projection Engine data files to the device by copying them (sideloading) or downloading them directly to the device.