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

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