Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
s_arun
Posts: 3
Registered: ‎12-02-2010

Can a library reference resource files from an application?

Hey folks! 

 

I have a doubt related to the use of resource files in an application. Any help on this issue will be useful. My issue is as follows:

 

I have a library which exposes a set of functions that different BB applications can use. While working on this over a period of time, I have ended up making a host of changes that has caused several parameters to be added to a particular method inside the library.

 

To overcome this, I thought of the approach of letting the user pass a resource file as a parameter (or a ResourceBundle object) which the library reads and obtains the parameters

 

Is there a way this can be done? From what I've read, it's required to have a compiled resource file (.rcb) as part of the jar and cod files.

 

Will this ever be possible if the resource file is part of the application and it is being referenced by the library?

Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Can a library reference resource files from an application?

welcome to the support forums.

 

by design a library cannot reference the application, it would not be a library if it could.

of course you can give a library constructor or method call any parameters you want, be it a string pointing to a file or a byte array representing a file you read or...

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
s_arun
Posts: 3
Registered: ‎12-02-2010

Re: Can a library reference resource files from an application?

Thanks for the reply! 

 

I do realize that I can get away with passing a parameter of any type to the method in my application. However, the resource files seems to be something different (I think!). To reference this file I guess I need it inside my workspace/jar/cod file.

 

As you are saying that I can use any type of parameter I want, could you please tell me how I can access the contents of the resource file through the "<ResourceFileName>Resource.java" interface, especially since that interface is now part of the application workspace?

 

Thanks again for your help!

Please use plain text.
Developer
simon_hain
Posts: 13,754
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Can a library reference resource files from an application?

you cannot use (blackberry language) resource files as parameters as they are built internally on compile time, not on runtime.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
s_arun
Posts: 3
Registered: ‎12-02-2010

Re: Can a library reference resource files from an application?

Thanks again! 

 

So what you're saying is that I cannot pass a ResourceBundle/ResourceBundleFamily object from my application to one of my library methods? That's too bad. Is there a workaround to this situation?

 

I guess another way would be to whip up an xml file with the list of parameters and use them accordingly.

Please use plain text.