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: 412
Registered: ‎09-12-2008
My Device: 9000 9810

File system access not allowed

Hi all.

 

I have already written about this subject but want this separate thread to have this issue separated from Mass storage questions.

 

My app writes to and reades from its settings on the file system.

The problem arrises when User plugs in the USB and has Mass storage turned ON (talking about Bold right now).

 

My app cannot access the file system at that time.

 

I make a check this way:

public static boolean isFileSystemAccessible() { boolean result = false; FileConnection file = null; try { file = (FileConnection)Connector.open("file:///store/home/user/", Connector.READ); if (file.canRead()) { result = true; } } catch (IOException ex) { app.println("testAccessFileSystem() ex(1)", ex); result = false; } finally { if (file != null && file.isOpen()) { try { file.close(); } catch (IOException ex) { app.println("testAccessFileSystem() ex(2)", ex); result = false;

} } } return result; }

 And it works properly.

So if User wants to make any change he is prompted that the file system is inaccessible and is denied to make the change.

 

1) But the question is: is this the proper way to go ?

  I've seen other devices (e.g. Opera mini) allowing the user to make any change he wants even when the file system is (allegedly)  not accessible.

2) (Of course, they could store the changes in memory, but then the changes would not be ther when the phone reboots, right?)


 

P.S.  My app stores its application under "file:///store/home/user/appName/" and must use the filesystem to enable administrators to change some parameters written in them across multiple devices/platforms.

 



"Listen carefully, I shall say this only once"
Developer
Developer
Posts: 319
Registered: ‎07-20-2008
My Device: Not Specified

Re: File system access not allowed

The best place to store program options is in the PersistentStore rather than the file system.
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: File system access not allowed

yes. But it's a requrement from the customer.

 

I could store it in the PersistentStore, and then try to sync with the filesystem, but it is impossible to know when will the admin access the files, and I would have to sync PS and file system exactly before that second. 

 

So I guess I'm stuck with handling a lot of Exception traffic Smiley Sad

It's tricky to remain kind to the User while at the same time he can do whatever he wants Smiley Happy - for instance I have to deal with the fact that maybe the User will plug in the USB at axactly the worst moment. And maybe he will play with the USB plug (IN/OUT/IN/OUT....).

 

Thx for your input.

 

 



"Listen carefully, I shall say this only once"
New Developer
Posts: 7
Registered: ‎06-08-2009
My Device: Not Specified

Re: File system access not allowed

I have just hit this problem (and wasted a few hours trying to work out why Smiley Sad ) and was wondering if anyone found a solution to this issue ?

In my instance it would basically make the application unusable (or at least in a restricted read only mode) when connected to a PC.

 

Jason

Developer
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: File system access not allowed

First, this is the regular behavior of the BB device.

Second, not every time you connect the USB. There is an option to disable the behavior and you will be able to read/write to the SDCard even with the USB connected.

Just make the " Auto Enable Mass Storage Mode When Connected" under option to either "No", or "Prompt" so it will ask and warn whenever connected to USB.

 

Well this is how it is. You need to make your app detect this mode and behave correctly.

 

Rab  

Highlighted
New Developer
Posts: 7
Registered: ‎06-08-2009
My Device: Not Specified

Re: File system access not allowed

Thanks for the reply, I was affraid of that, there is no way to ensure that the users have that so, as you say, I'll just have to live with it.

 

Jason