title: Getting NULL when open file in C code by JNI in android
body: <p>I'm calling C code by JNI in android app.</p>
  
  <p>Every thing is OK in calling, but when I put this code:</p>
  
  <pre><code>FILE* fp = fopen("/storage/sdcard0/input.txt","w+");
  if(fp==NULL)
      return(*env)-&gt;NewStringUTF(env,"n");
  else
      return(*env)-&gt;NewStringUTF(env,"y");
  </code></pre>
  
  <p>it gets "n". I'm sure that the path is true and I tried this command on my mobile's terminal:</p>
  
  <pre><code>cat /storage/sdcard0/input.txt
  </code></pre>
  
  <p>and it got me the file's contents. </p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I tried to change the permission of the file by this code but it gave me the same response:</p>
  
  <pre><code>void changePerm()
  {
      Process chperm;
      try {
          chperm=Runtime.getRuntime().exec("su");
  
  
     DataOutputStream os = 
            new DataOutputStream(chperm.getOutputStream());
          os.writeBytes("chmod 777 /storage/sdcard0/input.txt\n");
          os.flush();
  
          os.writeBytes("exit\n");
          os.flush();
  
            chperm.waitFor();
  
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  }
  </code></pre>
  
  <p>I also add this permission and no thing changed:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  </code></pre>