Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry® World™ Development

New Developer
Posts: 6
Registered: ‎06-02-2009
My Device: Not Specified
Accepted Solution

Multiple COD modules and mp3s

Hi everybody.


Our company makes PC games, and is branching out into various other formats; iPhone, Blackberry, etc.


I'm making a Blackberry version of one of our games which is somewhat larger than traditional Blackberry apps.  Right now all the assets etc. come out to be about 7 megs (note most of these aren't loaded concurrently, there are multiple screens, phases, etc.)  So here are my questions.


1) The documentation seems to imply that there is no limit on COD file size after version 4.0 came out.  However, we seem to have hit a wall at about the 6 MB mark.  After that I start getting weird errors when I start up the simulator about not being able to find classes like Bitmap and Resource.  Once I remove the resources that put me over the limit, everything goes back to working.  Can anyone confirm or deny this size limit?


2)  I've been able to avoid the first issue by splitting things up into multiple projects.  So I have a Library project with the assets for a certain part of the game, and another cod library with assets for another part of the game, plus a cod file with all of the code.  This works fine for loading up graphics when I use the Bitmap.getBitmapResource() that also takes a module name.  However, now I have an issue with sounds.  If I put the game's sounds in a separate cod module, I don't see any mechanism by which I can retrieve them from that module when I need to create the javax.microedition.media.Manager object using the getResourceAsStream().  Does anyone have any experience trying to load a sound from a separate cod module? It seems that no matter what I use I seem to end up with a null stream object.  I've tried using a class in the sounds module as the parent of getResourceAsStream() like this...




And the basic getClass().getResourceAsStream(filename) in about every combination I can think of... putting the file at the base level, or nested where I actually want it folder structure wise, using the "/" before the filename (and leaving it off), but no matter what combination I use I end up with a null stream.  Any help anybody could give me would be greatly appreciated.


Thanks in advance,





Posts: 95,816
Likes: 24,597
Solutions: 6,409
Registered: ‎04-01-2008
My Device: Passport • Z30 • Z10 • Torch9850 • Playbook
My Carrier: Verizon

Re: Multiple COD modules and mp3s

I have asked that this thread be moved to the Developer section of this forum, you will more likely get **intelligent** answers there.  Smiley Wink

1. If any post helps you please click the Like Button below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes
Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4   Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA   Display/Scan Bar Code
New Developer
Posts: 6
Registered: ‎06-02-2009
My Device: Not Specified

Re: Multiple COD modules and mp3s

oops... my bad for posting in the wrong group!


Thanks for moving it for me!



Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Multiple COD modules and mp3s

[ Edited ]

If a cod file is bigger than 64Kb (in some rare cases 65-67K) it is splitted to sibling cod files. You get one big cod file that has zip format, and all cod files are inside.


I have no information about size limit of cod files. But I think it is good to make them as small as possible.


You can store resources into cod files and access them from another cod files.


Let say you have a sound file MySong.mid located in MyApp.cod


then you can access this midi file via url: cod://MyApp/MySong.mid


Note that big and small letters does matter.


This approach is not documented but it does work.


In case you have questions related to the Java development post them here:




and check this link:




Message Edited by tbilisoft on 02-06-2009 09:47 PM
New Developer
Posts: 6
Registered: ‎06-02-2009
My Device: Not Specified

Re: Multiple COD modules and mp3s

Hey, thanks for the quick answer.


I wasn't able to get the cod:// to work for me, but I like the idea.  If you had a code sample I'd like to see it.


However, I was able to fix my problem by having a class with a static method in the library cod file that gets the InputStream object and returns it to the main application in the main cod.  Thought I'd post my method in case anybody else runs into a similar issue.

Trusted Contributor
Posts: 178
Registered: ‎02-20-2011
My Device: 8700
My Carrier: at&t

Re: Multiple COD modules and mp3s

“then you can access this midi file via url: cod://MyApp/MySong.mid”

How is it that can access , it is a cod sample that if you had?

# I tried to change the world, but I couldn't find the source code #