I have a android project and within that project I have a folder that contain some images.Now what i want is to access that folder within a jni function. So how should I do that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An Android application is essentially a zip file, but there are a lot of nice helpers to get to those resources. First thing you need to remember is that these files are not actually in a folder, unless you put them there.
That said, there are a number of possible solutions for you situation.
JNI (almost) all the way
The most JNI-y way to go about things is to use have a method like
in your
Activity, and use JNI to pry all the necessary resources from it, put them somewhere on disk, and process them.Mix in a bit of Java
Probably an easier way is to have some Java code that helps with the resource management; something like
and do the native processing based on the
byte[].Prepare files on the file system
A third solution is to move the files out of your bundle and onto the file system, and then point your native code to that directory.
So?
In the end, it all depends on what you exactly want to do with your resources, and whether or not they really need to be on the file system. I would keep things as close to Java as possible, and only go native when you really have to (e.g., your image manipulation code).