title: NDK load assets
body: <p>I'm using this method to load assets in NDK:</p>
  
  <pre><code>jclass localRefCls = myEnv-&gt;FindClass("(...)/AssetLoaderHelper");
  helperClass = reinterpret_cast&lt;jclass&gt;(myEnv-&gt;NewGlobalRef(localRefCls));
  myEnv-&gt;DeleteLocalRef(localRefCls);
  
  helperMethod1ID = myEnv-&gt;GetStaticMethodID(helperClass, "getFileData", "(Ljava/lang/String;)[B");
  
  ...
  
  myEnv-&gt;PushLocalFrame(10);
  
  jstring pathString = myEnv-&gt;NewStringUTF(path);
  jbyteArray data = (jbyteArray) myEnv-&gt;CallStaticObjectMethod(helperClass, helperMethod1ID, pathString);
  
  char* buffer = new char[len];
  myEnv-&gt;GetByteArrayRegion(data, 0, len, (jbyte*)buffer);
  
  myEnv-&gt;DeleteLocalRef(pathString);
  myEnv-&gt;DeleteLocalRef(data);
  
  jobject result;
  myEnv-&gt;PopLocalFrame(result);
  myEnv-&gt;DeleteLocalRef(result);
  
  return buffer;
  </code></pre>
  
  <p>in java:</p>
  
  <pre><code>public static byte[] getFileData(String path)
  {
  InputStream asset = getAsset(path); //my method using InputStream.open
  
  byte[] b = null;
  try
  {
      int size = asset.available();
      b = new byte[size];
      asset.read(b, 0, size);
      asset.close();
  }
  catch (IOException e1)
  {
      Log.e("getFileData", e1.getMessage());
  }
  
  return b;
  }
  </code></pre>
  
  <p>It works but when i load many assets there is crash or system locks. Am I making any mistake or someone knows better method to load assets to NDK? Perhaps it is only problem with low memory in my device?</p>