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
Highlighted
Developer
Posts: 511
Registered: ‎05-31-2009
My Device: Not Specified
Accepted Solution

Where can you create files on Storm1/Storm2/Bold2?

Hello gents. I'd like to find out where (which path) files should be created on the Storm 1 (jpeg images), as well as on the Storm2 and newest Bold.

 

On a Storm 9530 simulator, I tried to create a file with this path:
file:///store/Device Memory/home/user/pictures/filename.jpg
and got a FIleIOException- File System Error: Invalid Operation. Why it is invalid may be because you can't create files in code in this directory, but I'm not certain. The code is below.
 
    private static void SaveBitmap(byte[] bitmapBytes, int number) {
        
        OutputStream out = null;
        FileConnection filecon = null;
        String exceptionText = null;
        
        String path = GetPathToBackgrounds();
        // path = file:///store/Device Memory/home/user/pictures/

        try {
            
            filecon = (FileConnection) Connector.open(path + "MDBcurrentBackgroundPlus" + number + ".jpg", Connector.READ_WRITE);   
            
            if (!filecon.exists())
                    filecon.create();
                    
             out = filecon.openOutputStream();
             out.write(bitmapBytes);
             out.close();
        }
        catch (net.rim.device.api.io.file.FileIOException e) {
         
            int code = e.getErrorCode();  // 12 on Storm
            String msg = e.getMessage();

 

If there is a path where you *can* create jpeg files, I'll just use that, but what is it... not just for the Storm 1, but the Bold 2/Storm 2.

 

Cheers as always

Justin D.

Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Where can you create files on Storm1/Storm2/Bold2?

Hey justin, i do not think that that file path is valid.

 

Try just getting rid of the device memory and having something like this...

"file:///store/home/user/conversations/"

 

I use this path in my application and it works perfectly, oh and dont forget to close your filecon object.

filecon.close()

Like all of my posts
Developer
Posts: 511
Registered: ‎05-31-2009
My Device: Not Specified

Re: Where can you create files on Storm1/Storm2/Bold2?

Hi. No dice. On the Bold 9000 sim and handset (4.6), if you go into the Media app and look at the path shown in Properties for the images in the samples that come with the phone/sim, it is this

 

system/samples/pictures/filename.jpg

 

and sure enough, in code you can create an image which you can find in the app Media->Pictures->Sample pictures by using this

 

file:///system/samples/pictures/filename.jpg

 

But not on the Bold 9700, and if you try on the Storm 1 9530, it throws an exception. On the 9700 (5.0) it just goes into a hole, with no Exception.

 

I'd appreciate a link for more info on this, anyone, so I needn't trouble folks.

 

Cheers

J

 

 

 

 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Where can you create files on Storm1/Storm2/Bold2?

[ Edited ]

3rd party apps cannot access the system folder. You can only access the file:///SDcard and file://store/home/user directories.

Developer
Posts: 511
Registered: ‎05-31-2009
My Device: Not Specified

Re: Where can you create files on Storm1/Storm2/Bold2?

Thanks Kyle! It didn't let me create the file in that directory, but I tried making the directory

 

file:///store/home/user/pictures/MyDir/

 

and creating it in there, and it worked! The 'path' shown in Properties is wrong from a coding point of view Smiley Sad

 

Justin.

 

Developer
Posts: 511
Registered: ‎05-31-2009
My Device: Not Specified

Re: Where can you create files on Storm1/Storm2/Bold2?

Tks. All works fine on the Bold 2, and Storm 1, but now the Storm 2 needs something. Is the path

 

file:///store/home/user/pictures/MDB/

 

okay on Storm 9550, or if not, what path to use? No error message, but it doesn't work.

 

J.