04-23-2010 06:31 AM
I've seen it mentioned a few times and I'd REALLY need to know this.
How can I place my resources in a different, updateable cod? (I need to read some text-only configuration files that control the application's features.)
I created an "appNameres.cod" file (contains config text files), and it installs to the phone.
It also appears in the "modules" listing on the device (listed as "appNameres").
However, when I use
String filename = new String("cod://appNameres/appconfig.cfg");
InputStream is = file.getClass().getResourceAsStream(file);It doesn't find the file I need.
Can anyone help me?
Solved! Go to Solution.
04-23-2010 07:18 AM
I have a simple Class in my separate resources COD that I pass what resource name I want and it returns the Stream to it. It might not be the way that you want it but it reduces the problems of making it work.
04-23-2010 07:37 AM
Interesting idea, but could I ask you to provide with a bit more info?
How do I call the class?
Say I have
class ResLoader
{
public static InputStream loadResource(String filename)
{
InputStream is = file.getClass().getResourceAsStream(filename);
return is;
}
}this class.
HOW exactly do I use it (sorry for the caps but I am kind of desperate here
).
04-23-2010 08:29 AM
Something like:
class Res
{
public static InputStream getResourceStream(String file)
{
return Res.class.getResourceAsStream(file);
}
}Just make sure you use a class in that COD file so it looks for resources in that COD file.
04-23-2010 09:30 AM - edited 04-23-2010 10:15 AM
Okay, I'm being borderline stupid here.
I added
import rimbbresloader;
...
InputStream is = rimbbresloader.loadResourceFile("appconfig.cfg");
...
And when I hit build on the main project, it dies with the error:
[javac] C:\Work\proj\work\fctmain.java:1973: cannot find symbol
[javac] symbol : variable rimbbresloader
[javac] location: class fctmain
[javac] InputStream is = rimbbresloader.loadResourceFile("appconfig.cfg");
[javac] ^
[javac] 1 error
Also I (kinda have to) use eclipse. How could I import the blackberry JDE-built library into eclipse?
PS: Before getting this job I only used NetBeans (a bit), Code::Blocks and Visual Studio, oh and notepad. Eclipse and ant are pretty much arcane magic
to me.
04-23-2010 02:22 PM
I've finally managed to build the application, loaded the library resource *.cod to the simulator, loaded the app *.cod to the simulator but I get the following error : "Can't find entry point".
The application does not run.
04-23-2010 03:06 PM
@rcmaniac2: Okay! I've managed to make it run. And it loads the resources too. ![]()
Now, I have another issue, the library requires for permissions to be set to "Allow".
Otherwise it gives me "Interprocess Communication" error and quits.
Any points on that?
04-23-2010 07:15 PM
Do you have the resources COD compiled as a Library?
04-24-2010 01:10 AM
I think you're getting that error because accessing a COD from another COD requires the COD's to be signed, or have the permissions set to allow the same in your settings.
04-24-2010 07:37 AM
I have a COD that contains resources and a COD that contains code, I never have to sign the resource COD and the COD that contains COD only needed to be signed when I added functions that required signing so I don't think you need to sign it in order to get it to work.