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.

inside custom component

Java Development

Reply
Developer
Posts: 168
Registered: ‎11-22-2009
My Device: 9000 Bold, 8300 Curve
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?

 

 

 

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

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

And the exception is.....

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

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.

Developer
Posts: 168
Registered: ‎11-22-2009
My Device: 9000 Bold, 8300 Curve

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.

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
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.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" 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.
Developer
Posts: 168
Registered: ‎11-22-2009
My Device: 9000 Bold, 8300 Curve

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.

Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
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.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" 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.