How can get raw file from jni native c++
<p>I'm making a simple app in Android. I'm using NDK to make JNI calls. I have a file in a resource subfolder (raw), which I need to access from native c++ code. I want to read it from native using for example "ifstream" function but I don't get to do that. </p>

<p>That's my Java code:</p>

<pre><code>Algorithm algorithm = new Algorithm();

    InputStream isModel = getResources().openRawResource(R.raw.model);

    String model = algorithm.ReadResourceFile(isModel);

    if(imgInput != null &amp;&amp; txtResults != null)
    {
        Bitmap bmp = ((BitmapDrawable)imgInput.getDrawable()).getBitmap();

        //Convert Bitmap to Mat
        Mat image = new Mat(bmp.getHeight(), bmp.getWidth(), CvType.CV_8U);

        //Print results on txtResults
        String results = algorithm.DetectEmotionByImage(image.nativeObj, model);
        txtResults.setText(results);
    }
</code></pre>

<p>That's my C++ code:</p>

<pre><code>JNIEXPORT jstring JNICALL
Java_org_ctic_emoplay_1android_algorithm_Algorithm_DetectEmotionByImage(JNIEnv *env,
                                                                        jobject instance,
                                                                        jlong image,
                                                                        jstring fileModel_,
                                                                        jstring fileRange_,
                                                                        jstring fileModelFlandmarks_,
                                                                        jstring fileHaarCascade_)
{
    const char *fileModel = env-&gt;GetStringUTFChars(fileModel_, NULL);

    SVM_testing testing;

    Mat* imageInput= (Mat*)image;
    Mat&amp; inImageInput = *(Mat*) imageInput;

    string results = testing.TestModel(inImageInput, fileModel);

    const char* final_results = results.c_str();

    env-&gt;ReleaseStringUTFChars(fileModel_, fileModel);

    return env-&gt;NewStringUTF(final_results);
}
</code></pre>

<p>Anyone can help me? I'm desperated. Thanks!</p>