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
Developer
schepurny
Posts: 168
Registered: ‎11-22-2009
Accepted Solution

Unable to open an input steam on another .cod

I think this is a setup problem. This works fine using the simulator. But not on my Blackberry.

 

I have put a bunch of .csv files in another Blackberry Project called CSV.

 

My main project opens an InputSteam to read on of these files from the other project (let's call it ProjectA:

 

 is = (InputStream) Connector.openInputStream(

        "cod://CSV/" + company.csvFilename);

 

 

I get an exception on my Blackberry. Is there something that I need to do special when adding ProjectA to my Blackberry so that it can still "see" the CSV project?

 

 

 

 

 

Please use plain text.
Developer
peter_strange
Posts: 17,719
Registered: ‎07-14-2008

Re: Unable to open an input steam on another .cod

And the exception is.....

Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009

Re: Unable to open an input steam on another .cod

If I'm not mistaken only applications signed with RIM internal apps key (these signatures aren't available to third-party application developers) can use the "cod" protocol. I suspect your code works in the simulator only because you are running the simulator with security checks disabled. I'm also guessing that the exception you are getting is a ControlledAccessException.

Please use plain text.
Developer
schepurny
Posts: 168
Registered: ‎11-22-2009

Re: Unable to open an input steam on another .cod

[ Edited ]

I had a catch(Exception) in there so I had to fix that up to show the real exception.

 

Yes that's it ControlledAccessException.

 

I guess I'm stuck using the file:// protocol now and putting all of my csv files into the same project or is there some better way? I believe that I can use the file:// protocol to access files within my .cod but I still not sure what the correct path is to use.

Please use plain text.
Developer
rcmaniac25
Posts: 1,789
Registered: ‎04-28-2009
My Carrier: Verizon

Re: Unable to open an input steam on another .cod

[ Edited ]

Not necessarily, you could create a class that contains a function to get the resource for you.

 

This way instead of doing {Class Variable}.getResourceAsStream, you would do something like ResourceClass.getResource and inside that it gets that class's Class and does the same getResourceAsStream. This way you maintain separation of resources and it will still work.

 

At least that's how I did it.

 

EDIT: Oops, didn't realize that you weren't using getResourceAsStream, either way it will return the desired result.

------------------------------------------------------------
Three simple rules:
1. Please use the search bar before making new posts.
2. Kudo posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
schepurny
Posts: 168
Registered: ‎11-22-2009

Re: Unable to open an input steam on another .cod

Thanks for everyone's help! I initially didn't want to do things that way, but at this point I think that's the way that I'll go.

Please use plain text.
Developer
rcmaniac25
Posts: 1,789
Registered: ‎04-28-2009
My Carrier: Verizon

Re: Unable to open an input steam on another .cod

Understandable, sometimes getting something working is better then getting it to work the way you want it to.

------------------------------------------------------------
Three simple rules:
1. Please use the search bar before making new posts.
2. Kudo posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.