Data Sources are the main way you get data into your application.
Data Sources available to your app are divided into two categories:
- SQL DB (Local Data Source): Data Sources exist on the device as a SQL Lite database
- Live Feeds (Remote Data Sources): Data sources exist on device as an RSS, XML, ... feed.
The difference is reviewed in SQL DB and Live Feed
In this Tutorial we review the settings of an on device SQL DB data source (formerly known as Local Data Source).
- Create an On Device SQL DB
- Update SQL DB
- Download XML Descriptor and DB
Create an On Device SQL DB
Overview of on device SQL DB
- Creates a relational SQLite database.
- These databases are stored on the device and are accessed locally by the app.
- You can query the SQL DB using standard SQL queries (via Action: Execute SQLite Statement)
- In both cases, this post-processing occurs at the time the source data is converted into a relational database and not in the app itself.
Update a SQL DB
When you have made changes in either a Cloud Collection set to generate a SQL DB or a feed (RSS, XML, ..) set as a SQL DB you need to reprocess the feed in order to refresh the data in the on device SQL DB.
Manual update from a Cloud Collection
A manual update is donee using "Publish Latest" under Connect after selecting the appropriate Cloud Collection.
This will tell the Eachscape Server which hosts the data of the feed, to check the URL that is being used XML-RSS input file of the Local Data Source and grab a fresh copy of the data. This step happens automatically a few times an hour but this process does that immediately and thus is the fastest way to get data into apps that are installed on user's devices.
Each of these SQL DB can be set up to automatically reprocess when the source data changes (the source data comes from either an RSS, XML,.. feed or a Cloud Collection.
For these changes to materialize the updated Database must be set as Downloadable.
The database that is produced by the app can be bundled into the app so that when it is initially installed it will have data available or it can download the data on first use.
In addition, the replacement of the database can occur after the app is installed. The app can even be configured to refuse to run if the data becomes stale. Read more about Managing SQL DB Updates further down on this page.
Note that it is necessary to select the Downloadable checkbox in order to enable any of the features other than bundling a static copy of the database into the app.
Managing SQL DB UpdatesYou can set the frequency of how often the app looks for updates.
Only SQL DB can be set for timed on device updates.
These SQL DB are marked with an orange icon
The first step is to make sure your SQL DB (Local Data Source) is set as Downloadable.
Then go to the Studio (Develop Tab) to configure the Refresh frequency of your SQL DB.
In our example we attached our BBC News in SQL DB data source to the 'Hello World' app.
When the SQL DB is
- Attached to an app
- Set as Downloadable
When you OVER HOVER the data source name the setting icon appear, click on the icon.
On this Setting page, make sure Hosted is selected.
Then you can specify the Check After and Refuse After intervals.
The most frequent setting that you can specify is 1 hour intervals however, since the data is created on one server (possibly an Eachscape Cloud Collection) and then hosted on another Eachscape server (which automatically updates a few times an hour) it could be quite a bit longer than ab hour that the app sees fresh data.
Tricks for working with Local Data Sources while you are editing an app
There is another option which you can use if you plan on making changes to your local data sources while you are working with an app. In the Edit Database Settings screen you can specify that the app NOT include any data when the app is generated, by unchecking the Include Data With Build checkbox. This would mean that the app would start with no data and have to download it on first install. If you are updating your app and want to see changes you are making to the feeds (for instance within your Eachscape Cloud Collection), you could then delete the app from your device and reinstall it back on your device to see the newest changes to your data sources since it would have downloaded it freshly from the server upon first install.
Advanced Topic: After an XML, Merged or Tabular data source is processed, a SQLite database is created. If the data source is marked as downloadable (see above) then you can download the database and a small XML file that your app uses to validate the database. To do this, follow these steps:
- Make sure the data source is marked as downloadable
- Associate the data source with an app
- Look at the app and click on that data source (in the Navigation Panel).
- Note the URL, it will be something like http://builder.eachscape.com/assocs/670/edit except the number will be some other number. This is called the “Association ID”.
If the Association ID is 670, then the URL for downloading the database would be http://builder.eachscape.com/feeds/download/670.db and http://builder.eachscape.com/feeds/download/670.xml would access the XML descriptor.
The format of the XML descriptor and database are subject to change, but in general, you can use the SQLite3 program to open and review the contents of the database.