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
yog123
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified
Accepted Solution

Problem with File System and Media card file renaming ...

hiii guys,

 

i m developing application in which i have to rename file from media card  so i use FileConnection API.

but it gives me exception that File System Error and same code works fine for device memory files.

 

I m confused abt this one ...Is there any setting for Media card access..???.

 

code snippet

 

           fconn = (FileConnection)Connector.open(file:///SDCard/BlackBerry/pictures/2.jpg ,Connector.READ_WRITE);
                       
           
            if (fconn.exists())
            {
                System.out.println("" + fconn.canRead() + fconn.canWrite());
                fconn.rename("1.jpg");
                fconn.close();
                return true;
            }

 

 fconn.canRead() retruns me true

 fconn.canWrite() returns me true.

 

help me out guys....

 

Thanks in advance....

JDE 4.2.1

Device Simulator- 8100

Please use plain text.
Developer
kzettel
Posts: 120
Registered: ‎07-16-2008
My Device: 9000

Re: Problem with File System and Media card file renaming ...

Which exception is your application throwing and which line of your code is throwing the exception?  It details the causes of the different exceptions in the FileConnection javadocs.  Some of the things that may cause this:

  • If "1.jpg" already exists. 
  • If your sdcard is pointing to a directory on your local filesystem it could be a problem with security settings for that folder or file.  If Windows file permissions are set to read-only or restricted by user on the file or folder it may cause you to get errors. 
  • Another application has the file open which is locking the file.
Kurt Zettel | Chief Architect | Metova
www.metova.com
Please use plain text.
Developer
yog123
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: Problem with File System and Media card file renaming ...

fconn.rename("1.jpg") throwing exception as IOexception File System Error

 

and also i m unable to delete file which is on sdcard folder (created in my app)

 

show me the way..........

 

how to check if file system is locked or not....Any APIs are there??

 

thnks in advance....

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,649
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem with File System and Media card file renaming ...

Were the files created by your application?  If so, please ensure that all connections to them have been closed otherwise you could be locking your own file.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
yog123
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: Problem with File System and Media card file renaming ...

hii

 

thnks for reply 

 

but question remains same ...

 

Since i m moving file from device memory to Sd card code works fine...

 

But in opposite case Sd card to Device memory  i create file on device memory and tries to delete file on SD card it gives meexception asIOException: File System Error though i used different  file connection objects and also closing them properly....

 

Is thr any way to see if file is locked or not...???

 

I m bit confused about it since all code works fine on device memory but fails on SD card (rename,delete)...

 

 

Thnks in advance....

Please use plain text.
Developer
yog123
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: Problem with File System and Media card file renaming ...

hiii

 

I lastly found it....

 

My mistake of not closing input stream ofone of the files so it locks itself...

 

Thnks for help.....

 

 

Please use plain text.