MCPcopy Create free account
hub / github.com/android/ndk-samples / GetExternalFilesDirJString

Method GetExternalFilesDirJString

teapots/common/ndk_helper/JNIHelper.cpp:518–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516}
517
518jstring JNIHelper::GetExternalFilesDirJString(JNIEnv* env) {
519 if (activity_ == NULL) {
520 LOGI(
521 "JNIHelper has not been initialized. Call init() to initialize the "
522 "helper");
523 return NULL;
524 }
525
526 jstring obj_Path = nullptr;
527 // Invoking getExternalFilesDir() java API
528 jclass cls_Env = env->FindClass(NATIVEACTIVITY_CLASS_NAME);
529 jmethodID mid = env->GetMethodID(cls_Env, "getExternalFilesDir",
530 "(Ljava/lang/String;)Ljava/io/File;");
531 jobject obj_File = env->CallObjectMethod(activity_->clazz, mid, NULL);
532 if (obj_File) {
533 jclass cls_File = env->FindClass("java/io/File");
534 jmethodID mid_getPath =
535 env->GetMethodID(cls_File, "getPath", "()Ljava/lang/String;");
536 obj_Path = (jstring)env->CallObjectMethod(obj_File, mid_getPath);
537 }
538 return obj_Path;
539}
540
541void JNIHelper::DeleteObject(jobject obj) {
542 if (obj == NULL) {

Callers

nothing calls this directly

Calls 1

CallObjectMethodMethod · 0.80

Tested by

no test coverage detected