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 primitives in the native store

  1. In StoreType.java, add the newly managed integer type to the enumeration:
    public enum StoreType {
        Integer,
        String
    }
  2. Open Store.java and define the new integer functionalities our native store provides:
    public class Store {
        ...
        public native int getCount();
        
        public native int getInteger(String pKey);
        public native void setInteger(String pKey, int pInt);
    
        public native String getString(String pKey);
        public native void setString(String pKey, String pString);
    }
  3. In the StoreActivity class, update the onGetValue() method to retrieve integer entries from the store when they are selected in the GUI:
    public class StoreActivity extends Activity { ... public static class PlaceholderFragment extends Fragment ...

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