Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 {
        ...
        public static class PlaceholderFragment extends Fragment {
            ...
            private void onGetValue() {
                ...
                switch (type) {
                case String:
                    mUIValueEdit.setText(mStore...