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
New Contributor
rameshl
Posts: 6
Registered: ‎12-09-2010
My Device: Not Specified
Accepted Solution

Getting the Folder size as negative value

When we try to caculate the size of the particular folder(Which is available in device memory), its giving always negative value.
           
Software version6.0.0.141 (Platform 6.4.0.64)
Device model9800
 
            Code:
                        fileDirectory = "file:///store/home/user/documents/"
                        FileConnection fconnForDirect = (FileConnection) Connector.open(fileDirectory, Connector.READ_WRITE);
                        int folderSize = (int) fconnForDirect.availableSize();
 
                        Api Usage : javax.microedition.io.file.FileConnection                                              javax.microedition.io.Connector
 
            Note: The same code is giving expected size in Simulator and alll other versions.
Awaiting for the response :mansad:
Developer
paulkayuk
Posts: 133
Registered: ‎04-30-2010
My Device: Curve 8520

Re: Getting the Folder size as negative value

FileConnection.availableSize() returns a long not an int.  So, if the folder size returned is greater than the max size for an int, it will give you a negative int when you cast it to an int.  Try:

 

long folderSize = fconnForDirect.availableSize();

New Contributor
rameshl
Posts: 6
Registered: ‎12-09-2010
My Device: Not Specified

Re: Getting the Folder size as negative value

Hi..

 

      Thank you very much for reply. It worked. Thanks again.

 

 

Thanks and Regards,

Ramesh.L