David
David

Reputation: 1

BlackBerry FileIO: Delete files with specific extension

I'm working on a blackberry application which do some file handling, I would like to know how I can check a specific folder and delete only files with a specific extension. For example, I only want to delete my .log files.

Upvotes: 0

Views: 231

Answers (2)

drafael
drafael

Reputation: 146

FileConnection dir = (FileConnection) Connector.open(path);
Enumeration dirContent = dir.list("*.*", true);

FileConnection file = (FileConnection) Connector.open(filePath);
if (file.exists()) {
    file.delete();
}

Upvotes: 1

Vit Khudenko
Vit Khudenko

Reputation: 28418

Please, spend some time studying the FileConnection API. It has everything you need.

Upvotes: 1

Related Questions