On Tue, May 10, 2011 at 12:57 PM, Jim <[email protected]> wrote:
> I am trying include a small data file with my package.  I need to pass
> the name of the datafile down to a JNI native 'c' function that will
> open and read the file.  I am confused as to where to put this file.
> I've tried in res/raw, and in assets, but I can't seem to get an
> absolute pathname to where these files live to give to the 'c'
> routine.
>
> I supposed I could use AssetManager to open a fd and pass that down to
> the C code, but that is not how my existing library works at the
> moment.
>

That's probably not going to work reliably, even if you managed it.
The latest NDK allows you to create an activity entirely in native
code, so it probably has API's to access assets (haven't used it).

> How can I get the absolute path to an asset file or resource file, and
> can it be opened by the 'c' code?
>

The easiest way is to copy the file on the file system (or SD card),
in your app's onCreate() the first time you run it, and pass the
absolute path to your native code from there.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to