以下来自 NDK 的作品不使用 Java:
const char* path = app->activity->internalDataPath;
if (!path) {
JNIEnv* jni;
app->activity->vm->AttachCurrentThread(&jni, NULL);
jclass activityClass = jni->GetObjectClass(app->activity->clazz);
jmethodID getFilesDir = jni->GetMethodID(activityClass, "getFilesDir", "()Ljava/io/File;");
jobject fileObject = jni->CallObjectMethod(app->activity->clazz, getFilesDir);
jclass fileClass = jni->GetObjectClass(fileObject);
jmethodID getAbsolutePath = jni->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;");
jobject pathObject = jni->CallObjectMethod(fileObject, getAbsolutePath);
path = jni->GetStringUTFChars((jstring)pathObject, NULL);
jni->DeleteLocalRef(pathObject);
jni->DeleteLocalRef(fileClass);
jni->DeleteLocalRef(fileObject);
jni->DeleteLocalRef(activityClass);
app->activity->vm->DetachCurrentThread();
}