O'Reilly logo

Android NDK Beginner's Guide 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 exceptions from the Store

Let’s start by creating and catching exceptions on the Java side:

  1. Create a new exception class InvalidTypeException of type Exception in package com.packtpub.exception as follows:
    public class InvalidTypeException extends Exception {
        public InvalidTypeException(String pDetailMessage) {
            super(pDetailMessage);
        }
    }
  2. Repeat the operation for two other exceptions: NotExistingKeyException of type Exception and StoreFullException of type RuntimeException instead.
  3. Open existing file Store.java and declare thrown exceptions on getter prototypes only (StoreFullException is a RuntimeException and does not need declaration):
    public class Store { static { System.loadLibrary("store"); } public native int getInteger(String ...

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