On-Device-Data Genie

Description

When you build Cordova or TransForm applications, you may want to store data (SQLite databases, images, movies, audio files, PDF files, etc.) on the mobile device so that the files can be accessed when there is no internet connection. The On-Device-Data Builder can be used to generate the manifest that defines the data to download to the device.

Discussion

The On-Device-Data Builder makes it easy to define the manifest and to upload the manifest files to an Amazon S3 bucket from where they can be downloaded to a mobile device.

To open the On-Device-Data Builder select the Tools/More.../On-device-data builder for TransForm/PhoneGap applications... menu item.

images/ondevicedatamenu.jpg

This will then open the builder, as shown in the image below.

images/ondevicedatabuilder.jpg

The builder allows you to specify the data (i.e. files) you want to store on the mobile device. The builder allows you to define multiple item types of data. The available types are:

Type
Description
Folder

You can specify multiple files (you can use wildcard file specifications) that should be downloaded to a folder on your mobile device. The files are zipped into a single file to optimize download to the mobile device and then are unzipped on the mobile device.

File

Similar to the Folder option, but allows you to select a single file that will be downloaded and stored in the target folder on your mobile device.

SQLite database

A SQLite database. You can either specify the filename for a SQLite database file that already exists on your machine, or you can create the SQLite database by specifying one or more queries that extract data from SQL databases, web services, static data, etc.

URL

The URL of some existing remote file that you want to download and store on the mobile device.

For each item, you can also specify an optional version number. This is used by the Javascript method that downloads the manifest files to the device to determine if a file specified in the manifest must be downloaded. If a file has been previously downloaded it will not be downloaded again if its version number does not exceed the previous version number.

After you have defined all of the items in your manifest, you can save your definition by clicking the Save button. The settings are saved in a file in the Web Projects folder. You can then click the Generate manifest files button. This button will create the SQLite database files (if you specified that the SQLite database file should be created by executing queries) and it will create the necessary zip files (for example, for the Folder item type, all of the specified files are zipped into a single zip file).

Once the manifest files have been created, you can then upload them to Amazon S3. Click the Upload manifest files to S3 button to upload the manifest files. A manifest file will also be created and uploaded to S3. The manifest is a JSON file that describes each file in the manifest. The URL for this manifest file is used in your Action Javascript when you define an action to Fetch manifest files. For TransForm users, the URL for this manifest must be specified when you define the on device data for your account in TransForm Central.

After the manifest files are uploaded you can click the Show manifest URL/JSON to see the manifest URL and the actual JSON data in the manifest.

Before you can upload manifest files to S3 you must first click the Define S3 Properties hyperlink to define properties of the S3 bucket where your manifest files will be uploaded. You must specify the storage connection string that points to your S3 bucket (go to Tools, Storage connection strings when the Web Control Panel has focus) and the folder within this bucker where the manifest files should be uploaded.