Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
fopen file from resource package?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
deki  
View profile  
 More options Aug 30 2009, 6:17 pm
From: deki <dcec...@gmail.com>
Date: Sun, 30 Aug 2009 15:17:18 -0700 (PDT)
Local: Sun, Aug 30 2009 6:17 pm
Subject: fopen file from resource package?
Hi list,

How can I get / generate a path for use in fopen in native code to
open a file say in res/drawable?

I realize it might not be possible entirely in native to generate that
path, even If I have to pass the path from java to c++ that would be
fine.

Thanks a bunch!

D


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dianne Hackborn  
View profile  
 More options Aug 30 2009, 7:39 pm
From: Dianne Hackborn <hack...@android.com>
Date: Sun, 30 Aug 2009 16:39:25 -0700
Local: Sun, Aug 30 2009 7:39 pm
Subject: Re: fopen file from resource package?

You can't; those files are packed into a single .zip and can't be
individually open.

--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RzR www.rzr.online.fr  
View profile  
 More options Aug 31 2009, 2:18 pm
From: "RzR www.rzr.online.fr" <www.rzr.online...@gmail.com>
Date: Mon, 31 Aug 2009 20:18:36 +0200
Local: Mon, Aug 31 2009 2:18 pm
Subject: Re: fopen file from resource package?

On Mon, Aug 31, 2009 at 1:39 AM, Dianne Hackborn<hack...@android.com> wrote:
> You can't; those files are packed into a single .zip and can't be
> individually open.

One workaround is to put (and rename) the files into lib folder ...
I did this in some JNI application ...

Regards

--
Related Obsession : http://rzr.online.fr/q/jvm


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anders Johansson  
View profile  
 More options Oct 9 2009, 8:34 am
From: Anders Johansson <svi...@gmail.com>
Date: Fri, 9 Oct 2009 05:34:24 -0700 (PDT)
Local: Fri, Oct 9 2009 8:34 am
Subject: Re: fopen file from resource package?
I'm not sure about Resources, but you can do it with Assets through a
hack...

1. In Java, get your apk file path through
PackageManager.getApplicationInfo(...)
2. In java, get offset and size of asset in the apk through
Context.getAssets().openFd().getStartOffset()/getLength()
3. In JNI/C, open your apk file, seek to offset and read size bytes
into a buffer
4. ???
5. Profit!

I leave no guarantees on forward compatibility and/or portability, but
it works... :)

regards
Anders

On Aug 31, 12:17 am, deki <dcec...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dianne Hackborn  
View profile  
 More options Oct 9 2009, 12:50 pm
From: Dianne Hackborn <hack...@android.com>
Date: Fri, 9 Oct 2009 09:50:55 -0700
Local: Fri, Oct 9 2009 12:50 pm
Subject: Re: fopen file from resource package?

Um be sure you close the fd.  And really, just pass the fd along with the
start offset and and offset through to JNI.  I guarantee that will work, it
is how the API is intended to be used (regardless of native code).  Assuming
that the start offset and end offset are absolute positions in your .apk is
not guaranteed to work in the future.  (For example, what happens if one day
we decide that when an app is installed we unpack its .apk into individual
files?)

--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve  
View profile  
 More options Oct 11 2009, 8:28 am
From: Steve <rockthesm...@gmail.com>
Date: Sun, 11 Oct 2009 05:28:38 -0700 (PDT)
Local: Sun, Oct 11 2009 8:28 am
Subject: Re: fopen file from resource package?
Hi there, from reading this thread, I am thinking the best way for me
to acess all my assets, from native code, would be to bundle all my
assets into a single WAD/DAT file, and then include this as an asset
for the Java side to see. There are then a couple of Java side API
calls that I can make, to get the files start address in memory, and
also ths size, I can therefore just pass these two values across to
the native code and access it. Is this correct?

Would it be at all possible for someone to provide me with the Java
side calls to do this? I am looking through the various resource
functions and am not sure which one I need, and making sure if any
file handles are opened making sure they are closed etc.

Finally, roughly on topic, I also want to be able to write out a save/
settings file somewhere, could anyone give me in a nudge in the right
direction for what I should be doing here? I'd like to write out this
file from the native side ideally, but if that simply isn't possible I
could put the data I want to write out in to memory, and then get the
Java code to write this data out, presumably?

Many thanks for all your help,

Steve

On Oct 9, 5:50 pm, Dianne Hackborn <hack...@android.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »