Converting Java strings in native code

The first kind of entry we will handle is strings. Strings, which are represented as (almost) classic objects in Java, can be manipulated on the native side and translated to native strings, that is, raw character arrays, thanks to JNI. Strings are a first-class citizen despite their complexity inherent to their heterogeneous representations.

In this part, we will send Java strings to the native side and translate them to their native counterpart. We will also convert them back to a Java string.

Note

The resulting project is provided with this book under the name Store_Part5.

Get Android NDK Beginner's Guide - Second Edition 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.