安卓开发,在jni环境中获取手机外储存路径

别说谁变了你拦得住时间么 提交于 2019-12-05 17:45:31
    jclass envClz = (*env)->FindClass(env, "android/os/Environment");
    jmethodID getExternalStorageDirectory = (*env)->GetStaticMethodID(env, envClz,
                                                                      "getExternalStorageDirectory",
                                                                      "()Ljava/io/File;");
    jobject jobject1 = (*env)->CallStaticObjectMethod(env, envClz, getExternalStorageDirectory);

    jmethodID getAbsolutePath = (*env)->GetMethodID(env, (*env)->FindClass(env, "java/io/File"),
                                                    "getAbsolutePath",
                                                    "()Ljava/lang/String;");
    jstring jstring1 = (*env)->CallObjectMethod(env, jobject1, getAbsolutePath);
    const char *path_utf = (*env)->GetStringUTFChars(env, jstring1, NULL);
    LOGE("%s", path_utf);
    (*env)->ReleaseStringUTFChars(env, jstring1, path_utf);

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!