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

Native Development

Reply
Developer
cmr1990
Posts: 61
Registered: ‎10-16-2013
My Device: Z10
Accepted Solution

Free space on sd card

Is there any way to check if i have free space on my sd card?

something like : sdCardInfo.isFreeSpaceAvailabe() ??

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Free space on sd card

Under Qt there is QSystemStorageInfo but I haven't tried it under BB10.

 

If it doesn't work then simply writing a temp file (the size of your likely output) to the SD card and seeing if any errors are returned would work (if slightly hacky).


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
cmr1990
Posts: 61
Registered: ‎10-16-2013
My Device: Z10

Re: Free space on sd card

Better still, found it myself!

we could use :

https://developer.blackberry.com/native/reference/cascades/bb__filesysteminfo.html

the function fileSystemCapacity() could work for us!

 

#include <bb/FileSystemInfo>
 
const QString SD_MOUNT_POINT = ...;
 
qint64 getSDCardCapacity()
{
    FileSystemInfo fileSystemInfo;
 
    return(fileSystemInfo.fileSystemCapacity(SD_MOUNT_POINT));
}

 

Thanks anyways!!

Cheers!! :smileyvery-happy:

Please use plain text.
Developer
BrajeshSanodiya
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10

Re: Free space on sd card

[ Edited ]

#include <bb/FileSystemInfo>
bool deviceHasFreeSpace(QString destinationFileSystem)
{
bb::FileSystemInfo fileSystemInfo;

qint64 freeSpace = fileSystemInfo.availableFileSystemSpace(destinationFileSystem);
if (freeSpace == -1) {
qWarning() << "Failed to get free space - " << fileSystemInfo.errorString()<< "(" << fileSystemInfo.error() << ")";
return(false);
}
return(true);
}

https://developer.blackberry.com/native/reference/cascades/bb__filesysteminfo.html

-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Please use plain text.