O'Reilly logo

Android NDK Beginner's Guide - Second Edition 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 – handling strings in the native store

Let's handle String values in our store:

  1. Open StoreType.java and specify the new String type our store handles in the enumeration:
    public enum StoreType {
        String
    }
    Open Store.java and define the new functionalities our native key/value store provides (for now, only strings):
    public class Store {
        ...
        public native int getCount();
    
        public native String getString(String pKey);
        public native void setString(String pKey, String pString);
    }
  2. In StoreActivity.java, retrieve string entries from the native Store in the onGetValue() method. Do it according to the type StoreType currently selected in the GUI (even if there is only one possible type for now):
    public class StoreActivity extends Activity { ...

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