Write file to location other than SDcard using Android NDK?

You can always access the directory in which your app is placed. This directory is usually : data/data/<Your_package_name_usually com.android.appName>/files/<your_filename> but better use getFilesDir() to ensure valid filepath with future version changes of android. If you wanna use external storage instead, make sure you place this line of code in your app manifest to gain permission. … Read more

Generating Java interface with SWIG

You can achieve what you’re looking for with SWIG+Java using “Directors”, however it’s not quite as straightforward mapping from the C++ abstract classes onto Java as you might hope. My answer therefore is split into three parts – firstly the simple example of implementing a C++ pure virtual function in Java, secondly an explanation of … Read more

passing string array from java to C with JNI

You can write a simple function that takes a jobjectArray object, cast each one to jstring and then call GetStringUTFChars on it. Like this: void MyJNIFunction(JNIEnv *env, jobject object, jobjectArray stringArray) { int stringCount = env->GetArrayLength(stringArray); for (int i=0; i<stringCount; i++) { jstring string = (jstring) (env->GetObjectArrayElement(stringArray, i)); const char *rawString = env->GetStringUTFChars(string, 0); // … Read more

Eclipse reported “Failed to load JNI shared library” [duplicate]

First, ensure that your version of Eclipse and JDK match, either both 64-bit or both 32-bit (you can’t mix-and-match 32-bit with 64-bit). Second, the -vm argument in eclipse.ini should point to the java executable. See http://wiki.eclipse.org/Eclipse.ini for examples. If you’re unsure of what version (64-bit or 32-bit) of Eclipse you have installed, you can determine … Read more