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 Developer
ttjoseph
Posts: 9
Registered: 05-09-2009

Can't read files in OS 5.0 simulator

I'm trying to get my application working in the OS 5.0 (9000) simulator, but my file I/O code no longer works. So I've started over, writing the simplest code possible and working from there. If I do this:

 

String url = "file:///SDCard/testing.txt";
FileConnection fc = null;
try
{
    fc = (FileConnection) Connector.open(url, Connector.READ);

} catch (IOException e) {  }

 

It does not open testing.txt. fc.exists() and fc.canRead() both return false. I've set up a directory on the host computer to represent the SD card contents, added a file called testing.txt, and verified that fc.list() is able to enumerate the filenames in "file:///SDCard/" - including testing.txt. Why can it find the file name but not open the file? The RIM-supplied "Files" application is able to show me the filename but is unable to read the file (shows the text file icon next to the filename but shows a blank screen when I try to view it).

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

Re: Can't read files in OS 5.0 simulator

What are the stack trace and the detail message of the exception?

Please use plain text.
New Developer
ttjoseph
Posts: 9
Registered: 05-09-2009

Re: Can't read files in OS 5.0 simulator

No exception is thrown; Connecter.open() just returns an unusable FileConnection instance.

Please use plain text.
New Developer
ttjoseph
Posts: 9
Registered: 05-09-2009

Re: Can't read files in OS 5.0 simulator

Also forgot to mention that using the "store/" filesystem root does work, it's just "SDCard/" that exhibits this strange behavior.

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

Re: Can't read files in OS 5.0 simulator

Can you read files in the /home/user/ subdirectory on the SDCard?

Please use plain text.
New Developer
ttjoseph
Posts: 9
Registered: 05-09-2009

Re: Can't read files in OS 5.0 simulator

No, I can't read any files, but I can traverse directories (e.g. FileConnection.list()).

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

Re: Can't read files in OS 5.0 simulator

Can it be a Windows (Vista?) permissions problem, since we are talking about the SDCard of the simulator?

Please use plain text.
New Developer
ttjoseph
Posts: 9
Registered: 05-09-2009

Re: Can't read files in OS 5.0 simulator

[ Edited ]

I had checked the permissions as well; they include read access for all users. Anyhow the simulator executable should be running as my username and I can open these files using Notepad etc...

 

Edit: I am running Vista, sadly enough.

 

Thanks for your help!

Please use plain text.
Developer
Developer
gtj
Posts: 319
Registered: 07-20-2008

Re: Can't read files in OS 5.0 simulator

I have the same issue and I think it's a bug in the 5.0 simulator when it's set up to use a directory on the pc filesystem as the SDCard.  All of the earlier simulators work fine.

 

Please use plain text.
New Developer
JayGu
Posts: 26
Registered: 10-27-2009

Re: Can't read files in OS 5.0 simulator

I have the same problem under 5.0.

Everything is ok with 4.7

Please use plain text.