title: Using byte[] from Java to native (C++) code using JNI
body: <p>I am doing Android development in Java, with some native parts (external libraries) written in C++.</p>
  
  <p>I'd like to pass a byte[] from the managed (Java) application to the native (C++) library:</p>
  
  <pre><code>// Declaration for the native method in Java
  private native void someMethod(byte[] data);
  </code></pre>
  
  <p>On the native side, i'd like to use the byte array as arguments to another provided native function.</p>
  
  <p>I've read about a JNI method for converting (copying) the array data into a compatible type (<em>GetByteArrayElements</em>), however that leaves me with a <em>jbyte *</em> type, which is incompatible with the library i am using (The library defines it's own <em>nByte</em> type, which is an unsigned char).</p>
  
  <p>What would be the best option for this scenario?</p>
  
  <p>Should i stick to the method i've described using JNI, and convert the jbyte array type into the appropriate nByte array? any other option?</p>