Sparksee is the first graph database available for Android devices applications, available in two interfaces java and C++. In this article we will guide through a typical installation & configuration for the java interface, so you can start working with Sparksee in your mobile development environment in a few minutes.
To make sure your application development meets our requirements, Sparksee Android requires Platform level 9 (Android 2.3) and an Android SDK, while it supports the processors armeabi, armeabi-v7a, x86, mips.
Although you are free to work with the development environment that best suits your needs, for this quick tutorial we are going to suppose that you are either using:
a) Eclipse & plugin ADT + SDK
b) Android Studio + SDK
You will need to update or have installed the API platforms and the emulator.
Step 1) Downloading Sparksee
Download your Sparksee mobile library from our website here: http://www.sparsity-technologies.com/#download
We will send you an email on how to download your own copy. Downloads for mobile (like the licenses requests) are moderated, please wait until a support member contacts back.
Once you receive your download, unzip it & check the contents:
READ.ME: Basic Android sparkseejava instructions.
LICENSE.txt: License details.
ReleaseNotes.txt: Current version changes.
lib: Dynamic libraries.
doc: Sparksee documentation.
Step 2) Creating a new project linking Sparksee mobile library
Create an Android application project using the IDE (Eclipse or Android Studio) called (for instance) HelloSparksee
Follow the READ.ME instructions:
Copy all the content of the “lib” directory to the “libs” directory of your android project.
a) Eclipse option
Right click on the “libs/sparkseejava.jar” file and select “Build Path > Add to Build Path”.
Set in your “AndroidManifest.xml” a minimum sdk version >= 9
b) Android Studio option
In AndroidStudio, right click on the “libs/sparkseejava.jar” file and select “Add as library…”.
Add this exact text “compile files(‘libs/sparkseejava.jar’)” to the “build.gradle” file.
Set a minimum sdk version >= 9 in the “build.gradle” file.
Run the empty application! That’s it! You now have a new project using Sparksee.
Step 3) Initial steps
Now you should create a new Sparksee database, to make that follow this order of actions:
- Add the following import: import com.sparsity.sparksee.gdb.*;
- Now you should make some configuration steps before creating the database. First of all, create a new configuration class with SparkseeConfig cfg = new SparkseeConfig();
- Set the license code with SparkseeConfig.setLicense(key): Sparksee mobile only works with a valid key, you are going to get that code in the same email of your download.
- Limit the Sparksee cache memory with SparkseeConfig.setCacheMaxSize(MB): Sparksee by default takes all the free available memory space, but that is something you surely may control in a phone device.
- Activate the recovery functionality with SparkseeConfig.setRecoveryEnabled(true): The recovery is a helpful functionality that will allow you to recover all your data if any error occurs
- Set the log file with SparkseeConfig.setLogFile(filename): Specify a log full name&path where you have write permission
- Create the main Sparksee class with new Sparksee(cfg): take into account that the argument of this method is the SparkseeConfig created.
- You have already configured Sparksee, now let’s create your database with Sparksee.create(filename)). Again you will need name&path as happens with the log.
- It’s time to create a session session with Gdb.newSession()
- Graph objects and operations are available at Graph class level; you need to get the graph from the session with Session.getGraph()
Continue creating your nodes, edges and interact with them, check our documentation to keep working. Make sure to close everything properly and in the following order: close session, close database and finally close sparksee.