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 Java arrays in native Store


To help us handle operations on arrays, let's download a helper library, Google Guava (release 18.0 at the time of writing this book) available at http://code.google.com/p/guava-libraries/. Guava offers many useful methods to deal with primitives and arrays, and perform "pseudo-functional" programming.

Copy guava jar in the project libs directory. Open the Properties project and go to Java Build Path | Libraries. Reference Guava jar by clicking on the Add JARs... button and validate.

  1. Edit the StoreType.java enumeration and add three new values: IntegerArray, StringArray, and ColorArray:

    public enum StoreType {
        ...
        Color,
        IntegerArray,
        StringArray,
        ColorArray
    }
  2. Open Store.java and add new methods to retrieve and save int, String, and Color arrays:

    public class Store {
        ...
        public native int[] getIntegerArray(String pKey);
        public native void setIntegerArray(String pKey, int[] pIntArray);
        public native String...