title: Handling java string into native C/C++ for Android Studio+NDK
body: <p>I am trying to build a program using Android Studio1.3.2 + NDK + Windows7.
  I want to pass a string from Java function to Native C function (const char*).</p>
  
  <p><strong>The native C function declaration is:-</strong></p>
  
  <pre><code>public native int HRFromJNI(String path);
  </code></pre>
  
  <p><strong>The Java function call is:-</strong></p>
  
  <pre><code>tv.setText(String.valueOf(HRFromJNI(path)));
  </code></pre>
  
  <p><strong>The Native C function is:-</strong></p>
  
  <pre><code>extern "C" {
    JNIEXPORT jint JNICALL
    Java_com_example_hellojni_HelloJni_HRFromJNI
    (JNIEnv *env, jobject obj,jstring path)
    {
      int HRval = 0;
      char *Path;
  
      Path = (*env)-&gt;GetStringUTFChars( env, path, null) ;
  
      HRval = filefunction(Path);
      return HRval;
    }
  </code></pre>
  
  <p><strong>The function called by the Native C function is :-</strong></p>
  
  <pre><code>int filefunction(char* filename)
  {
  FILE* file = fopen((char*)filename,"w+");
  //Reads value from the file and returns it.
  .
  .
  .
  }
  </code></pre>
  
  <p>But i get error "<strong>Base operand of -> has non-pointer type JNIEnv{aka _JNIEnv}</strong>"</p>
  
  <p>Is this the correct way of passing string to Native C code, or is there any other way to assign a string from Java to const char* ? </p>