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 { ...

Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.