How to Mine the Device-local AIRS Data?

In local sensing mode, AIRS stores the recorded values in a device-internal database. Applications like Storica allow for mining the data to provide engaging visualisations and alike.

Generally, there are the following two approaches to mining the recorded AIRS data, namely mining the data offline on your desktop or mining directly on your phone. We will elaborate on both in the following.

Mine the Data on your Desktop

In this approach, we describe how to transfer the recorded values from your device to your desktop and mine the data through, e.g., PHP scripts or Java programs.

For this, we utilise the synchronisation option of AIRS. Hence, we assume that you regularly synchronise your recordings and transfer the values via, e.g., Bluetooth, to your desktop.

On your desktop, save the text files you received through this synchronisation in a dedicated folder (say /AIRS_data for now).

Then, extract the Java package (which has been provided by Dana Pavel) that is included in the /getairsdata directory of the AIRS github distribution.

Configure the Java package by adjusting the two paths in the airs_settings.txt file. The first path is defined in AIRS_SENSORS and needs to point to the directory where you unpacked the package (and where the airs_sensors.txt file will be stored). The second path is defined in the AIRS_STORAGE path and needs to point to the directory where you save all synchronised AIRS text files.

Next, you will need to install MySQL properly on your desktop. Create an AIRS user and save the username and password in the airs_settings.txt file.

At the first ever run, you will need to call getairsdata_create.bat, which will create the appropriately tables in MySQL. It will also read any synchronisation files that exist in your storage directory and will write the values into the appropriate tables.

For any future integration of data, i.e., every time you will synchronise AIRS recordings with your desktop, you will need to run getairsdata_update.bat. The database tables will be updated accordingly.

With this procedure, you can maintain an updated recordings database on your desktop. You can now mine this database to your liking with the database tables that are created being similar to those maintained by AIRS on your mobile device.

Mine the Data on Your Mobile Device

The SQlite database that is created and maintained by AIRS is private to AIRS, increasing the security so that other applications cannot read your recordings.

There are ways, however, to allow specific applications to access your device-internal database (the format of this database being described here). For this, we use the Android mechanism called shared userID. Any application that (a) shares the same user ID and (b) is signed with the same certificate can share data among each other. Our Storica companion application utilises this mechanism to open the AIRS database and mine the data for visualisation as digital stories.

As a developer, you can use the same mechanism to develop applications that utilise AIRS recorded data. For this, you have to modify your application’s manifest.xml file to include the shared userID tag. For instance, the Storica manifest file starts like this

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.storica"
    android:versionCode="28"
    android:versionName="1.2.4"
    android:sharedUserId="com.airs" >

You can see the android:sharedUserID tag at the end of this declaration. Include this tag similarly in your own manifest file. In addition, you will need to create your own AIRS version by signing the AIRS package with the same certificate that you will use for your own application. Hence, even if you don’t change AIRS itself, you will need to download it and re-package it with your own certificate. NOTE that if you happen to have the original AIRS installed on your device, you will need to change the base package com.airs into something different (and also adjust the shared userID definitions accordingly) since Android will not allow for two applications to exist with the same package name but different certificates.

If you have now your own AIRS (signed with your own key), you can access the AIRS database in your own program like this:

try
{
  // get AIRS context
  Context context = this.createPackageContext(“com.airs”, Context.CONTEXT_INCLUDE_CODE);

  // get database
  database_helper = new OWN_DB(context);

  airs_storage = database_helper.getWritableDatabase();
}
catch(PackageManager.NameNotFoundException e)
{
  Log.e(“YOUR_APP”, “Error in getting AIRS database”);
}
catch(Exception e)
{
  finish();
}

where OWN_DB is defined as

public class OWN_DB extends SQLiteOpenHelper
{
  public static final String DATABASE_NAME = “AIRS”;
  private static final int DATABASE_VERSION = 2;

  public STORICA_DB(Context context)
  {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db)
  {
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
  {
  }
}

airs_storage will hold a reference to the AIRS recording database and you can issue SQL commands according to your needs. Access to the database even works when AIRS is running and recording!