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 – raising & catching exceptions in native Store


  1. Create the Java exception com.packtpub.exception.InvalidTypeException of type Exception as follows:

    package com.packtpub.exception;
    
    public class InvalidTypeException extends Exception {
        public InvalidTypeException(String pDetailMessage) {
            super(pDetailMessage);
        }
    }

    Repeat the operation for two other exceptions: NotExistingKeyException of type Exception and StoreFullException of type RuntimeException.

  2. Open Store.java and declare thrown exceptions on getInteger() in class Store (StoreFullException is RuntimeException and does not need declaration):

    public class Store {
        ...
        public native int getInteger(String pKey)
            throws NotExistingKeyException, InvalidTypeException;
        public native void setInteger(String pKey, int pInt);
        ...

    Repeat the operation for all other getter prototypes (strings, colors, and so on).

  3. These exceptions need to be caught. Catch NotExistingKeyException and InvalidTypeException...