O'Reilly logo

Android NDK Beginner's Guide by Sylvain Ratabouil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – building a native key/value store

Let’s take care of the Java side first:

  1. Create a new hybrid Java/C++ project like shown in the previous chapter:
    • Name it Store.
    • Its main package is com.packtpub.
    • Its main activity is StoreActivity.
    • Do not forget to create a jni directory at project’s root.

    Let’s work on the Java side first, which is going to contain three source files: Store.java, StoreType.java, and StoreActivity.java.

  2. Create a new class Store which loads the eponym native library and defines the functionalities our key/value store provides. Store is a front-end to our native code. To get started, it supports only integers and strings:
    public class Store { static { System.loadLibrary("store"); } public native int getInteger(String pKey); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required