MomTarsh
MomTarsh

Reputation: 23

Can't get File Descriptor for asset

I need to get a file descriptor for a dae file, so I can get the Start Offset and Length. I have got file descriptors for png files, which work fine. I did this by using this code.

int id = 0;
id = getResources().getIdentifier("duck", "drawable", getPackageName());
mAssetDescriptor = getResources().openRawResourceFd(id);

Like I said, for my png's this worked fine, for my dae's, however, this did not work, I got the following exception:

android.content.res.Resources$NotFoundException: File res/drawable/duck.dae from drawable resource ID #0x7f020030

mAssetDescriptor was null.

So I tried to do another way. I put my dae files in the assets folder

mAssetDescriptor = getAssets().openFd("duck.dae");

This came up with the error

This file can not be opened as a file descriptor; it is probably compressed.

What I would like to know, is how I can get the Start Offset and Length of the file without using the getFileDescriptor() and getStartOffset() functions, as it seems I can not use these.

I guess it is also worth nothing the dae files are all under 1mb, with duck.dae which i'm trying to load at the moment at 500k.

Thanks alot for the help

Tom

Upvotes: 2

Views: 5950

Answers (1)

Peter Knego
Peter Knego

Reputation: 80330

This probably works for pngs because they are not additionally compressed, while most other files are. See this thread: http://groups.google.com/group/android-ndk/browse_thread/thread/8274a4c51cc9cc1d

Try adding and extension to your files, that prevents file from being compressed.

Upvotes: 3

Related Questions