Skip to Content
Author's profile photo Jan Teichmann

How to create an Android app on SAP HANA One in 20 minutes

What’s new


Today, SAP HANA is one of the most compelling and innovative development platforms worldwide. It offers opportunities for various types of new applications which work on huge amounts of data and need very fast access to them. In this blog I focus on
  • data that originate in the Cloud or are best stored in the Cloud: therefore, HANA One ( in the Amazon Cloud, is the platform of choice
    • there are also other Cloud Service Providers running HANA One like Portugal Telecom or Korea Telecom and others, please search the Web for them
  • small smartphone apps that show the new opportunities in a very concise way and at the same time leverage all important aspects of the technology stack I start with a tutorial on Android.
I try to use the leanest setup possible. Therefore, in the base scenario, I don’t use HTML5, I just select data out of a simple table in HANA via the simplest possible SQL statement, but I do create a small HANA XS app because this is the way to connect to HANA directly via http/ https. There are some extension scenarios to show more technology to enrich your application, see at the bottom.
I did it on a Windows machine. But it should also run on other OS.

App idea

The example app I build further down is comparing some stock exchange data and their development over time. Therefore, I propose some fictive names for all the artifacts you will create.

Prerequisites and Installs

Before starting the app creation in 20 minutes we need to make sure to install the following components (this would exceed the 20 minutes…):
  • Get access to HANA One and start HANA
    • “Get your own SAP HANA One, developer edition on Amazon Web Services” ( parts 1, 2 and 5
    • Watch out, this alone might take some time
    • Of course, if you have a running local HANA instance (SPS6) and Studio installed, just use this one!
  • Install SAP HANA Studio locally and connect to HANA
  • Install Android SDK

Create an Android App

Create an Adnroid Application:
  • Start your Eclipse version that you installed for Android development.
  • In the Package Explorer of the Java perspective right-click “New –> “Android Application Project”.
  • Application Name “Android App on HANA base scenario”
  • keep all the other settings on New Adnroid Application Name screen as defaulted
  • Select any start icon you want on Configure Launcher Icon screen
  • Select a Blank Activity on the Create Activity screen
  • Use Activity name “ShowMarketPriceData” on the New Blank Activity screen
Give the application an Id:
  • In the the Package Explorer double click –> res –> layout –> activity_show_market_price_data.xml
  • Use the XML layout instead of the Graphical Layout tab (bottom) in the middle part and exchange the id-line in the <TextView … /> part with this one:
    • android:id=”@+id/MyTextResponse”
Allow access to the internet for the new app
  • In the Package Explorer double-click on AndroidManifest.xml
  • In the middle part of the screen, use the Permissions tab (bottom)
  • Add Uses Permission and assign name android.permission.INTERNET
Download additional library:
  • Download json-simple-1.1.1.jar for instance from
  • Put it into your lib directory, for instance C:\blabla\workspace_android\AndroidAppOnHANABaseScenario\libs\json-simple-1.1.1.jar
  • Right-click on Package Explorer double click –> libs and Refresh: it should show up
Add code to show some data (see also
  • In the the Package Explorer double click –> src –> com.example.androidapponhanabasescenario –>
  • Add imports at the top:
    • import android.widget.TextView;
    • import android.os.AsyncTask;
    • import android.util.Base64;
    • import;
    • import;
    • import;
    • import;
  • In public class ShowMarketPriceData add the following code:
  • In method onCreate, just below setContentView(R.layout.activity_show_market_price_data);
ShowDialogAsyncTask aTask = new ShowDialogAsyncTask();
  • Also add this method and private class:
public String getOdata() {
     String JASONrs = “You will get there!”;
                              // some more code is to come here
                              return JASONrs;
                          private class ShowDialogAsyncTask extends        AsyncTask<Void , Void , String>{
                              protected String doInBackground(Void… arg0) {
                                   return getOdata();
                              protected void onPostExecute(String result) {
                                    TextView tv = (TextView) findViewById(;
Use overall Save, again select activity_show_market_price_data.xml and click Run as Android Application
Your Android or Android Emulator should bring up a screen that shows “You will get there!”.
Congrats! For now, your done on the Android side!

Create a HANA XS app

Start your HANA Studio. Connect to your HANA (as described in the SCN link mentioned further up).
Create a new HANA workspace:
  • In the SAP HANA Development perspective in the SAP HANA Repositories window on the left, right-click and select “New repository workspace”
  • Select your HANA SYSTEM, put the name “CompareStockMarketData” and define the workspace root directory or leave it as defaulted
Create and share a project for SAP HANA XS:
  • In the SAP HANA Development perspective, in the Project Explorer on the left, right-click New –> Project and select SAP HANA Development –> XS Project, put name “androidapponhana”,  click Finish
  • In Project Explorer, right-click androidapponhana –> Team –> Share Project… 
  • Select your SAP HANA System, select Workspace Name CompareStockMarketData, (leave Repository package empty for now) and click Finish
Add necessary minimum artifacts
  • Within project androidapponhana, Right-click –> JavaScript Resources –> androidapponhana and select New –> Other
    • In the upcoming Wizard select General –> File and click Next, put “.xsapp” as name and click Finish (it shall remain empty for our purposes)
  • Do the same thing again – let’s call this proceeding XS artifact addition – and create file “.xsaccess
    • In the Project Explorer double click on file .xsaccess and put the following content into it
: true,
: [ { “method” : “Basic” } ]
  • Perform XS artifact addition and create file “COMPARE_STOCK.hdbschema” and put the following content into it
  • Perform XS artifact addition and create file “PRICE_HISTORY.hdbtable” and put the following content into it

table.schemaName = “COMPARE_STOCK”;
table.tableType = COLUMNSTORE;
table.columns = [
{name = “NSIN”; sqlType = SHORTTEXT; nullable = false; length = 12;  },
{name = “DATE”; sqlType = DATE; nullable = false; },
{name = “TIME”; sqlType = TIME; nullable = false; },
{name = “DAY_OPEN”; sqlType = DECIMAL; nullable = false; precision = 8; scale = 3;},
{name = “DAY_HIGH”; sqlType = DECIMAL; nullable = false; precision = 8; scale = 3;},
{name = “DAY_LOW”; sqlType = DECIMAL; nullable = false; precision = 8; scale = 3;},
{name = “DAY_CLOSE”; sqlType = DECIMAL; nullable = false; precision = 8; scale = 3;},
{name = “VOLUME”; sqlType = INTEGER; nullable = false; }
table.primaryKey.pkcolumns = [“NSIN”, “DATE”, “TIME”];

  • Perform XS artifact addition and create file “StockDataIF.xsodata” and put the following content into it
               service {
                    “androidapponhana::PRICE_HISTORY” as “History” ;
Click the overall Save button.
In Project Explorer, right-click androidapponhana –> Team –> Commit.
In Project Explorer, right-click androidapponhana –> Team –> Activate.
Now, grant privileges to your user and put some test data in:
  • Go to SAP HANA Studio, for instance to the Quicklaunch perspective, in the Navigator view on the left open an SQL COnsole
  • Type and execute (make sure to put your user instead of the placeholder):
  • Type and execute
    insert into “COMPARE_STOCK”.“androidapponhana::PRICE_HISTORY” ( NSIN, DATE, TIME, DAY_OPEN, DAY_HIGH, DAY_LOW, DAY_CLOSE, VOLUME ) values (‘000716460’, ‘20130205’, ‘130000’, 60.19, 60.55, 59.91, 60.2, 2313291);
Now open a browser and test (put IP address and port/HANA instance number of your HANA server instead of the placeholders):
Congrats! This was the HANA XS stuff. Let’s go back to the Adnroid side.

Calling the XS app from the Android App

Enhance Android Java code to show your HANA XS data:
  • In the the Package Explorer double click –> src –> com.example.androidapponhanabasescenario –>
  • In public class ShowMarketPriceData replace the line ”   // some more code is to come here” by:
          try {
                URL myhana = new URL(

                URLConnection hanacon;
               hanacon = myhana.openConnection();

               String userpass = “SYSTEM” + “:” + “<your pw>”;
               String basicAuth = “Basic “ + new String(Base64.encode(userpass.getBytes(), 0));
               hanacon.setRequestProperty (“Authorization”, basicAuth);

               BufferedReader in = new BufferedReader(new InputStreamReader(hanacon.getInputStream()));
               String inputLine;

               while ((inputLine = in.readLine()) != null) JASONrs += inputLine;
           } catch (Exception e) {
               return “Error”;
  • Make sure to replace user (for instance SYSTEM) and <your pw> (for instance manager).
  • Save and test your Android app. It shall return a lot of JSON text on your screen starting with the string “You will get there!”.
    Congrats! That’s it.
    Don’t be shocked – it should look like this,
    but in my next Blog I will make it look a little bit nicer 😉 !

    Closing remarks and extension Scenarios

    Now, of course this is just a “Hellow World!” type of application. But it shows nicely what technology can be used.
    So far, I will leave it to the user to imagine a more appropriate way of putting user credentials. To reach a good security level for an App you should think of: SSL, do save user credentials on local device not at all or only encrypted (use OAUTH if you can) and save local data in a secure way.
    In the subsequent blogs on this topic I will make it look nicer and put more business sense to it. I decided to also create tutorials for some extension scenarios. These are very much built on top of the base scenario, but they make the app look more appealing and they show a lot more interesting technology.
    1. Android: Show HANA data in a gridview
    2. Android: Show HANA data as a graph
    3. Android: Use HTML5 to show data
    4. XS: Show data from a CalcView
    5. XS: Show data tweaked by SQLScript

    Assigned Tags

        You must be Logged on to comment or reply to a post.
        Author's profile photo Former Member
        Former Member

        Awesome work guys.Should try creating android apps on HANA suite as soon as possible. Good luck ahead.Cheers !!


        SAP Consultant

        Nihon Tech Pvt Ltd.

        Author's profile photo Phani Rajesh Mullapudi
        Phani Rajesh Mullapudi

        Very well put together for starters to try it out.

        Author's profile photo Former Member
        Former Member

        Good work, thanks

        My problem is calling to HANA on the Cloud.

        I'm getting "Unable to resolve host" error when trying to call

        Please advise.

        Author's profile photo Jan Teichmann
        Jan Teichmann
        Blog Post Author

        Please check your access to the internet. From inside firewalls there might be special aspects to be looked at (especially because SAP HANA Studio needs some "unusual" ports open).


        Author's profile photo Former Member
        Former Member

        Thanks for the article. It is very informative.

        Author's profile photo Former Member
        Former Member

        Hello ,

        Thanks you very much for a nice tutorial,

        i am facing a issue i.e. i am not able to activate StockDataIF.sxodata file after i commit all my files of this project

        i am having a SAP HCP trail account of 30 days, i don't know whether this tutorial will accomplish successfully on this environment

        i have attached a screenshot of the same please see the attachment/wp-content/uploads/2015/06/active_error_xsodata_725979.png.

        can anyone please help to solve this out on the same

        Author's profile photo Jan Teichmann
        Jan Teichmann
        Blog Post Author

        The reason is that table PRICE_HISTORY.hdbtable is not active yet. You have to activate PRICE_HISTORY.hdbtable first (or use activate_all).

        Author's profile photo Former Member
        Former Member

        Thank you for your quick reply.

        i will do it that way and let you know.