Overview | Backend | App Configuration | Android | iOS |
MBO Android App | OData Android App |
OData Android Content:
In this section, we will cover migration concepts involved in the creation of the device’s local database
In MBO based mobile apps, the device local database is automatically created when needed by the Object API. In addition, the generated package database class contains methods that allow programmers to delete or create a device's local database manually.
In OData mobile apps, the device local database is created through the initialization of the Offline OData store. The Offline OData store is a class that represents a service endpoint that can be interacted via OData protocol. Please note the mobile app must have network connectivity to open a store for the first time. Subsequent attempts to open the store may be performed without network connectivity. The following flow diagram explains how the device local database is created during the initialization of the offline store.
Notice in the diagram that the mobile app requests the initial download with “defining requests”. The “defining requests” define the entire set of data that will be available offline. In this exercise we have created a custom class “OfflineStoreManager” to handle the offline store. Check the openOfflineStore method of this class, to understand how to set the defining requests and all other require information to open an offline store.
Developers must pay close attention to the way they set the defining request. For example, in order for entity relationships to be available on the client we need to use $expands in our defining requests. The $expand syntax is to name the navigation property that you want to expand, most OData producers do support $expand. For example:
options.addDefiningRequest("reg1", "BusinessPartners?$expand=SalesOrders/Items", false);
Mobile apps can open an offline store synchronously and asynchronously. For asynchronous calls, we can create a custom class “EntityCollection” to handle the creation of the offline store and a listener class “OfflineStoreListener” that implements ODataOfflineStoreListener that can be called upon reaching each stage during the initialization of the store. The interface ODataOfflineStoreListener defines four methods:
These classes would allow us to separate the backend requests from the user experience.
Please note we have submitted the sample application for publishing and it will be available in a Git repository soon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
31 | |
24 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |