Caching jfieldID, jmethodID, and referencing data to improve performance
This recipe covers caching in Android JNI, which can improve the performance of our native code.
Getting ready
You should make sure you've read the following recipes before going through this recipe:
- Accessing Java static and instance fields in native code
- Calling static and instance methods from native code
How to do it…
The following steps detail how to build a sample Android application that demonstrates caching in JNI:
- Create a project named
Caching
. Set the package name ascookbook.chapter2
. Create an activity namedCachingActivity
. Under the project, create a folder namedjni
. Refer to the Loading native libraries and registering native methods recipe of this chapter for more ...
Get Android Native Development Kit Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.