Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

This sample app showcases the functionality of an offline OData app.

Notifications You must be signed in to change notification settings

SAP-archive/cloud-sdk-android-offline-odata

Repository files navigation

Important Notice

This public repository is read-only and no longer maintained. For the latest sample code repositories, visit the SAP Samples organization.

SAP Cloud Platform SDK for Android Offline OData Sample

REUSE status

Description

This sample app showcases the functionality of an Offline OData app. The first time the app opens, it downloads a portion of the backend's data, enabling the user to make changes to the data locally. The user doesn't need a working internet connection to make changes once the initial download has completed. Working against an on device offline store instead of a remote backend can improve performance. When an internet connection is available, the user can synchronize their local changes with the backend.

This sample app will show how to indicate to the user which data has changed locally and has yet to be synchronized with the backend. Additionally, it will show how to deal with differences between data in the user's local database and the backend.

If you are new to the SAP Cloud Platform SDK for Android, Get Started with SAP Cloud Platform SDK for Android, Step by Step with the SAP Cloud Platform SDK for Android series, and the SAP Cloud Platform SDK for Android Learning Journey are great places to start.

The Finished Product

The app enables customer info to be viewed and edited.

App home screen

Let's start setting up this project!

Requirements

The blog Step by Step with the SAP Cloud Platform SDK for Android contains additional details on how to setup and install the SDK, how to register for a trial version of the SAP Cloud Platform, and how to enable Mobile Services.

Setting Up Mobile Services

The initial mobile services configuration for the offline project is included in the project folder. In the mobile services cockpit, navigate to Mobile Applications > Native/Hybrid and click the Import button.

Mobile Applications > Native/Hybrid > Import button

In the resulting prompt window, browse for the mobile_services/com.sap.offline_1.0.zip. Click Save.

Browsing for mobile services configuration

The imported project configuration will have an OAuth security endpoint that does not match your user name, so next, change the OAuth endpoint in the security section of the application to your own account. To do so, remove the current OAuth configuration in the Security section and create another one. Leave everything blank and click OK.

Deleting old oauth configuration

Adding oauth client

Click Save, and the rest of the details for the OAuth configuration such as Authorization Endpoint, Token Endpoint, End User UI, and Redirect URL will be filled in.

Save the OAuth configuration

Configuration

Open the project in Android Studio.

Click update if asked to update the Android Gradle plugin.

To successfully run the application, the OAuth string constants in the application need to be changed to reflect the new values. In the project, press Ctrl + N on Windows, or Command + O on Mac, and navigate to MainActivity.java and change the constants at the top of the file to match your username and client ID.

Update the constants at the top of the MainActivity file

Your username and OAUTH_CLIENT_ID string can be found in the mobile services cockpit, as shown below.

The OAUTH_CLIENT_ID string located in the mobile services cockpit

Run the project to deploy it onto an emulator or device. For further details on the app see DOCUMENTATION.md.

Known Issues

No known major issues.

How to obtain support

If you have questions/comments/suggestions regarding this app please post them using the tag SAP Cloud Platform SDK for Android or if you encounter an issue, you can create a ticket.

License

Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.