title: NDK C++ create File in Internal storage (and read/write to it)
body: <p>I have to following problem I just can't seem to fix:</p>
  
  <p>I have an Android application with an Activity that passes the Path of the internal Storage to C++ via JNI:</p>
  
  <pre><code>getFilesDir().getAbsolutePath() //this passed to C++ over JNI
  </code></pre>
  
  <p>I also tried variations like:</p>
  
  <pre><code>getDir("data", MODE_PRIVATE).toString()
  </code></pre>
  
  <p>However when arriving in C++ I have the following Code:</p>
  
  <pre><code>const char *path = (pathFromJava + "/someFileName.txt").c_str();
  std::ofstream stream;
          try {
  
          stream.open(path);
  
          if(stream.good()) {
              stream &lt;&lt; someDataToWrite;
  
              stream.close();
          }
      }
      catch (std::ios_base::failure&amp; e) {
          std::cout &lt;&lt; "Error no: " &lt;&lt; strerror(errno);
      }
  </code></pre>
  
  <p>Above when trying to "open" to file we arrive at the "catch" statement and it prints: "No such file or directory".</p>
  
  <p>(the std::ios_base::failure e doesn't have a meaningful message (ios failure is all it says = (e.what()))</p>
  
  <p>The path passed from Java looks like: "blablub/data/package.name/files".
  (seems to be fine)
  and the file should usually be created when non existing by opening the stream.</p>
  
  <p>I haven't found anything about required permissions for the internal storage.</p>
  
  <p>May I need to create the file in Java first?
  Or might the path not be the right one afterall?</p>
  
  <p>Thanks for some hints in advance</p>
  
  <ul>
  <li>Pascal</li>
  </ul>
  
  <p>PS: I am using the C++ code for the same app again in IOS - so writing the file stuff in Java would defeat the purpose of using C++ to have as much code as possible just once.</p>