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
Amit_K
Posts: 135
Registered: ‎08-27-2008
My Device: Not Specified
Accepted Solution

How to know available space on device programatically

Hello EveryBody,

 

I am developing the application such that Before downloading the files on Blackberry I want to check the free space on BlackBerry device

 

so, How to get the available free space programatically on BlackBerry Device ? ( which API should be used ? )

 

also if there is SDCard attached to device then how to get free space programatically on that SDCard also.

 

Thanks in advance. 

 

 

Please use plain text.
Developer
jjthrash
Posts: 31
Registered: ‎07-22-2008
My Device: Not Specified

Re: How to know available space on device programatically

Take a look at:

http://www.blackberry.com/developers/docs/4.3.0api/javax/microedition/io/file/FileSystemRegistry.htm...()

 and

 http://www.blackberry.com/developers/docs/4.3.0api/javax/microedition/io/file/FileConnection.html#av...()

 

You should be able to do something like (untested)

Enumeration roots = FileSystemRegistry.listRoots(); while (roots.hasMoreElements()) { String root = (String)roots.nextElement(); FileConnection conn = (FileConnection)Connector.open("file:///" + root); long availableSize = conn.availableSize(); }

 

Jimmy

 

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

Re: How to know available space on device programatically

Also, the Memory and MemoryStats classes can be used to get the free space on the built in flash on the BlackBerry.
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
Amit_K
Posts: 135
Registered: ‎08-27-2008
My Device: Not Specified

Re: How to know available space on device programatically

Thank you very much to both of you......... got the solution.

Please use plain text.